Inactivate customers using Mass update.

Jira code: TM 86

This task is to inactivate customers if the sales rep is House & no sales activity for the last 6 months.

Mass update script

/**
 * @NApiVersion 2.x
 * @NScriptType MassUpdateScript
 * @NModuleScope SameAccount
 * @ScriptId customscript_tm86_jj_inactv_cust
 * @ScriptTitle TM 86 JJ Inactive Customers
 * @AppliedTo Customer
 */
/*******************************************************************************
 * TAKE 5 MEDIA
 * **************************************************************************
 * Date: 29/06/2018
 * 
 * Author: Jobin & Jismi IT Services LLP
 * 
 * 
 * REVISION HISTORY :
 * 
 * Revision 1.0 $ 29/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;
    		
    		var custRecord = record.submitFields({
    			type:'customer',
    			id:recId,
    			values:{
    				
    				isinactive:true
    				
    			}
    		});
    		
    	}catch(e)
    	{
    		log.debug("Err@Customer Inactive Script",e.message);
    	}

    }

    return {
        each: each
    };
    
});

Leave a comment

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