N/piremoval Module Script Sample

The following script sample demonstrates how to use the features of the N/piremoval module.

Remove Phone Numbers and Comments from Customer Records

The following sample shows how to remove the phone numbers and comments in specific customer records from the record fields (field values), system notes, and workflow history. The removed values are replaced with removed_value.

Note:

This sample script uses the require function so that you can copy it into the SuiteScript Debugger and test it. You must use the define function in an entry point script (the script you attach to a script record and deploy). For more information, see SuiteScript 2.x Script Basics and SuiteScript 2.x Script Types.

            /**
 * @NApiVersion 2.x
 */

require(['N/piremoval'], function(piremoval) {
    function removePersonalInformation() {
        var piRemovalTask = piremoval.createTask({
            recordType: 'customer',
            recordIds: [11, 19],
            fieldIds: ['comments', 'phone'],
            workflowIds: [1],
            historyOnly: false,
            historyReplacement: 'removed_value'
        });
        
        piRemovalTask.save();
        var taskId = piRemovalTask.id;

        var piRemovalTaskInProgress = piremoval.loadTask(taskId);
        piRemovalTaskInProgress.run();

        var status = piremoval.getTaskStatus(taskId);
    };

    removePersonalInformation();
}); 

          

General Notices