Jira Code: AHD-121
To turn off and turn on the deployment of a scheduled script using another scheduled script.
/**
* @NApiVersion 2.x
* @NScriptType ScheduledScript
* @NModuleScope SameAccount
*/
/*******************************************************************************
* * Jobin & Jismi IT Services | AHD | AHD-121
* **************************************************************************
*
* Author: Jobin & Jismi IT Services LLP
*
* Date Created : 18-June-2019
*
* Created By: Maria Davis
*
*
*
******************************************************************************/
define(['N/record'],
function(record) {
/**
* Definition of the Scheduled script trigger point.
*
* @param {Object} scriptContext
* @param {string} scriptContext.type - The context in which the script is executed. It is one of the values from the scriptContext.InvocationType enum.
* @Since 2015.2
*/
function execute(scriptContext) {
try{
//To undeploy the scheduled script
var scheduledscript = record.load({
type: record.Type.SCRIPT_DEPLOYMENT,
id: 1802,
isDynamic: true,
});
scheduledscript.setValue({
fieldId: 'isdeployed',
value: false,
ignoreFieldChange: true
});
scheduledscript.save();
//To deploy the map reduce script
var mapreducescript = record.load({
type: record.Type.SCRIPT_DEPLOYMENT,
id: 2481,
isDynamic: true,
});
mapreducescript.setValue({
fieldId: 'isdeployed',
value: true,
ignoreFieldChange: true
});
mapreducescript.save();
}catch(e){
log.debug("execute",e);
}
}
return {
execute: execute
};
});