- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2018 02:48 PM
HI
I am trying to build JSON object to use in one of the integration. Below code works fine if used hardcoded value but fail if use workflow scratchpad variables. I am trying to execute this in service catalog workflow activity. anyone face same issue?
workflow.scratchpad.account_id = current.variables.account_id; //Works if hardcode value here
workflow.scratchpad.change_request = current.variables.change_request; ////Works if hardcode value here
workflow.scratchpad.number = getTaskNumber(current.sys_id);
var requestBody = {};
function getTaskNumber(requestItem){
var getTask = new GlideRecord('sc_task');
getTask.addQuery('requested_item',requestItem);
getTask.addQuery('active', true);
getTask.query();
while(getTask.next())
{
//gs.addInfoMessage("Task: " + getTask.number + " Staus: " + getTask.state);
var ticket_number = getTask.number;
return ticket_number;
}
}
requestBody.account_id = current.variables.account_id;
requestBody.change_request = workflow.scratchpad.number;
requestBody1 = new global.JSON().encode(requestBody);
workflow.info("JSON Body: " + requestBody1+ "\n " + "Function Return: " + workflow.scratchpad.number);
Output:
JSON Body: {"account_id":{},"change_request":{}}
Function Return: SCTASK0010044
Solved! Go to Solution.
- Labels:
-
Request Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2018 02:52 PM
Can you change below two lines to
requestBody.account_id = current.variables.account_id+'';
requestBody.change_request = workflow.scratchpad.number+'';
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2018 02:52 PM
Can you change below two lines to
requestBody.account_id = current.variables.account_id+'';
requestBody.change_request = workflow.scratchpad.number+'';
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2018 07:55 PM
Please mark the response correct if it worked for you
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2018 09:29 AM
Hi Sanjiv
Thanks for reply. It worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2020 05:12 AM
HI Sanjiv
This is strange behavior, it worked but can you please explain that why it happened.
Thanks,