is there a way to mass some parmas to our map/redu...
# suitescript
s
is there a way to mass some parmas to our map/reduce task? Context: I have a portlet that has a select field and based on what is chosen, a different internal id for our search would be used in the get input data stage of the map/reduce
a
Look at task.create, specifically the
params
option.
s
thanks, I'm stuck at the point receiving the params
Copy code
function getInputData(params) {
    log.debug("skipped", params);}
a
Try using
N/runtime
as outlined here
s
this is how im setting the params
Copy code
mrTask.params = {
        id_input: params.selectfield,
      }
a
you need to set the params when you create the task.
Copy code
var mrTask = task.create({
    taskType: task.TaskType.MAP_REDUCE,
    scriptId: 34,
    deploymentId: 'custdeploy1',
    params: {
        doSomething: true
    }
});
Then when you want to receive the params in the mapreduce task use:
runtime.getCurrentScript().getParameter('doSomething')
s
getting
Copy code
Untitled
the key inside params is
Copy code
doSomething: true   vs "doSomething": true
a
Shouldn't matter. Does your trigger look exactly as outlined above?
s
Copy code
let mrTask = task.create({
        taskType: task.TaskType.MAP_REDUCE,
        scriptId: "customscript873",
        deploymentId: "customdeploy2",
        params: {
          id_input: params.selectfield,
        },
      });
Copy code
var scriptObj = runtime.getCurrentScript().getParameter("id_input");
    log.debug(scriptObj);
a
And you get
Untitled
?
s
yup
a
Three points: • Try hardcoding params.selectfield to a string to test it. • Are you sure you are looking at the map reduce script that is triggered with the above
task.create
? • Would have thought it should be
undefined
Also you understand that
task.create...
has to be in a different script than
runtime.getCurrentScript()...
?
s
yup it is
one is a sutlet one is map/reduce
i forgot to create the parameter in the ui
@Alan Fitch Thank you for your help
z
just note : parameters must be defined on the script record
s
Yeah I learnt that the hard way