dennysutanto
04/09/2025, 12:55 PMCeligo AI
04/09/2025, 1:36 PMAI generated answer (using internal Slack threads):To pass a parameter from a User Event to a Map/Reduce script, you can use the script deployment parameters. Here's how you can do it: 1. In your User Event script, set the value of the script parameter for the Map/Reduce script. You can use the
N/task
module's submit
method to do this.
2. In your Map/Reduce script, you can read the parameter value using runtime.getCurrentScript().getParameter({name: 'custscript_your_parameter'})
.
Here's a sample code snippet:
User Event Script:
javascript
var mrTask = task.create({taskType: task.TaskType.MAP_REDUCE});
mrTask.scriptId = 'customscript_your_mr_script';
mrTask.deploymentId = 'customdeploy_your_mr_script';
mrTask.params = {
'custscript_your_parameter': 'your_value'
};
var mrTaskId = mrTask.submit();
Map/Reduce Script:
javascript
var scriptObj = runtime.getCurrentScript();
var paramValue = scriptObj.getParameter({name: 'custscript_your_parameter'});
To pass data to the summary function in a Map/Reduce script, you can use the context.write
method in the map or reduce stage, and then read it using context.output
in the summary stage. Here's a sample code snippet:
javascript
function map(context) {
// Write data to be passed to the summary stage
context.write({
key: 'your_key',
value: 'your_value'
});
}
function summarize(context) {
// Read data passed from the map or reduce stage
context.output.iterator().each(function (key, value) {
log.debug('Key', key);
log.debug('Value', value);
return true;
});
}
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
04/09/2025, 1:37 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841280043
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.839389205
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.8237589
Celigo AI
04/09/2025, 1:37 PM