Jira Code : BGGN-198
Description
Before triggering your scheduled script using a Restlet script, you need to non-schedule the existing Map reduce script.
JJ RL Trigger Auto fulfill SO BGGN-198
/**
* @NApiVersion 2.1
* @NScriptType Restlet
*/
define(['N/task'], (task) =>
{
/**
* Defines the function that is executed when a GET request is sent to a RESTlet.
* @param {Object} requestParams - Parameters from HTTP request URL; parameters passed as an Object (for all supported
* content types)
* @returns {string | Object} HTTP response body; returns a string when request Content-Type is 'text/plain'; returns an
* Object when request Content-Type is 'application/json' or 'application/xml'
* @since 2015.2
*/
const get = (requestParams) =>
{
try
{
var mrTask = task.create({
taskType: task.TaskType.MAP_REDUCE,
scriptId: 924,
deploymentId: 'customdeploy_jj_mr_merge_acf_bggn199',
params: {
doSomething: true
}
});
var handle = mrTask.submit();
var res = task.checkStatus({
taskId: handle
}); // Returns a RecordActionTaskStatus object
log.debug('Initial status: ' + res.status);
return "Success"
}
catch (e)
{
log.debug("Error @ get", e);
return "Failure"
}
}
return {get}
});
Here the scriptId and the deploymentId is the IDs of the Map reduce script.
After deploying the script, it will provide a internal and external URL to invoke the MR script.
The Map Reduce script will start its execution on clicking of the URL provided by the Restlet script.

