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 07:39 AM
Hi,
Unfortunately, you didn't provide any information, like a screenshot or example script so we can see.
Please show how you're retrieving a value from a catalog task...
Then show how you're using it going forward.
Format should be something like this when setting a catalog task value:
task.description = workflow.scratchpad.variable_name;
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- 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 06:22 AM
Hello
I'm glad my reply was Helpful in encouraging you to share more information, please mark it as such, if so.
For your code, please use appropriate logging, such as: gs.info() to see what values you are getting.
Does the u_choice field on this specific Request Item have an actual value?
What is the value of your scratchpad?
gs.info("***DEBUG - scratchpad value is: " + workflow.scratchpad.choice);
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2022 07:40 AM
Hi Souvik,
Can you share the run script and scratachpad variable definition, so that we can see how you are defining it and using it.
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)