Unable to get workflow scratchpad value in catalog tasks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 07:30 AM
I have used run script to retrieve a value from a catalog task and store it in workflow scratchpad. Then I have used the Advanced section of catalog tasks to populate a field value with the scratchpad value. In some of the tasks I can see the value being populated but after a few tasks the field value is not populating from workflow scratchpad. Why is this happening I can't understand.
This is the run script to retrieve value and store it in the scratchpad.
var ritm_sys_id = current.getValue('sys_id');
var gr = new GlideRecord('sc_task');
gr.addEncodedQuery('short_description=Test Task 1^request_item=' + ritm_sys_id);
gr.query();
if (gr.next()) {
workflow.scratchpad.choice = gr.u_choice;
}
And this is the script written in the advanced section of the catalog tasks.
task.u_choice = workflow.scratchpad.choice;
- Labels:
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 10:03 AM
Hey, I have provided the code. Please check once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2022 05:45 AM
Hi Souvik,
I have gone through your script. So for this value to get populated the below condition should work every time.
gr.addEncodedQuery('short_description=Test Task 1^request_item=' + ritm_sys_id);
So my question to you, have you checked the short_description of tasks? Is it same as 'Test Task 1'? If yes then it should work else not.
Plus this script will only work for future records you will create using the catalog item and not for the past records.
Please mark this as correct and helpful if it resolved the query or lead you in right direction.
Thanks,
Mohit Kaushik
Community Rising Star 2022
Mohit Kaushik
ServiceNow MVP (2023-2025)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 07:56 AM
I have added the scripts. Please check once.