I have a custom record where I need to delete all ...
# ask-stanley-ai
s
I have a custom record where I need to delete all records where my custom record field A is equal to 1234 - how can I do that?
c
AI generated answer (using internal Slack threads):
To delete all records where your custom record field A is equal to 1234, you can use a Map/Reduce script in SuiteScript. Here's a simplified example of how you can do it:
Copy code
javascript
/**
 * @NApiVersion 2.x
 * @NScriptType MapReduceScript
 */
define(['N/search', 'N/record'], function(search, record) {
    function getInputData() {
        return search.create({
            type: 'customrecord_your_custom_record',
            filters: [['custrecord_field_a', 'is', 1234]]
        });
    }

    function map(context) {
        var searchResult = JSON.parse(context.value);
        record.delete({
            type: 'customrecord_your_custom_record',
            id: searchResult.id
        });
    }

    return {
        getInputData: getInputData,
        map: map
    };
});
In this script,
getInputData
function creates a search that finds all records where field A is equal to 1234. The
map
function then deletes each of these records. Please replace
'customrecord_your_custom_record'
with your actual custom record type ID and
'custrecord_field_a'
with your actual field ID. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816943765
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816255689
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.810814738
Please provide your feedback on this answer.