Hi All: I am calling a MapReduce from a RESTlet ...
# suitescript
a
Hi All: I am calling a MapReduce from a RESTlet trying to pass the json body from the request through. Here is where I'm using task.create()
Copy code
var mapReduceScriptTask = task.create({
    taskType: task.TaskType.MAP_REDUCE,
    scriptId : 'customscript_gb_bulk_update',
    deploymentId : 'customdeploy_gb_transaction_bulk_update',
    params : {
        "custscript_requestbody" : request['recList']
    }
});
However, using log.debug() I'm seeing that Parameter empty on the MapReduce side here:
Copy code
function getInputData(context){
    var post_body = runtime.getCurrentScript().update_post.getParameter({name: 'custscript_requestbody'})
    log.debug({
        title:'In Get Input data Stage',
        details: update_post});
Any help is appreciated!
s
Copy code
function getInputData(context){
    var post_body = runtime.getCurrentScript().update_post.getParameter({name: 'custscript_requestbody'})
    log.debug({
        title:'In Get Input data Stage',
        details: update_post});
seems like all sort of wrong here? you're not logging post_body, and why are you even doing
Copy code
runtime.getCurrentScript().update_post.getParameter({name: 'custscript_requestbody'}
surely should be more like
Copy code
runtime.getCurrentScript().getParameter({name: 'custscript_requestbody'})
hopefully i dont discourage you, i only mean to point out the mistakes that I think are there (which by no means are correct), let me know if i can help further tho ^_^
a
No no, I appreciate it. You're correct, and I will update issues and retry. After hours of copy/pasting I must have gotten bleary eyed. Will update soon 🙂
@Sciuridae54696d I made the changes, and am still not sure what I'm missing to pull the Request into the Map Reduce.
Copy code
var post_body = runtime.getCurrentScript().getParameter({name: 'custscript_requestbody'})
log.debug({
    title:'In Get Input data Stage',
    details: post_body});
The Log shows up, but the details are blank. Any ideas what I may try?
b
Start with a hardcoded parameter
Edit the script deployment and hardcode a value in the script parameter field
Once you get that working, then move onto setting the script parameter in the task
a
Thanks @battk I'll give that a shot.