Delete all entries of a custom record using mass update

Jira Code: MR 106

Create a script to delete all the entries of a custom record. The custom record name is QPay market place Details.

Mass update script

/**
 * @NApiVersion 2.x
 * @NScriptType MassUpdateScript
 * @NModuleScope SameAccount
 * @ScriptTitle MR 106 Delete all Qpay Market.js
 * @ScriptId customscript_jj_mr106_mu_del_qpay_mark
 * @ScriptDeploymentId customdeploy_jj_mr106_mu_del_qpay_mark
 * @AppliedTo Qpay Market
 * @Description This script is used to delete all the Qpay Market custom record
 */
/*******************************************************************************
 * MEGATEL
 * **************************************************************************
 * Date: 16/06/2018
 * 
 * Author: Jobin & Jismi IT Services LLP
 * 
 * 
 * REVISION HISTORY :
 * 
 * Revision 1.0 $ 16/06/2018 aj : Created
 * 
 ******************************************************************************/
define(['N/record', 'N/search'],
/**
 * @param {record} record
 * @param {search} search
 */
function(record, search) {
    
    /**
     * Definition of Mass Update trigger point.
     *
     * @param {Object} params
     * @param {string} params.type - Record type of the record being processed by the mass update
     * @param {number} params.id - ID of the record being processed by the mass update
     *
     * @since 2016.1
     */
    function each(params) {
    	try{
    	//to get the id 
    	var recId=params.id;
    	// to delete the record
    	record.delete({
    	type:'customrecord_jj_qpay_marketplace_details',
    	id:recId
    	});
    	}catch(e)
    	{
    		log.error('err@ deletion',e.message);
    	}
    }

    return {
        each: each
    };
    
});

Leave a comment

Your email address will not be published. Required fields are marked *