- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2019 09:55 AM
I have a Workflow that create and Incident, I have 3 subflows that are creating tasks for different processes.
Is it possible at all to get the Incident sysID from the scratchpad in the main workflow to the Subflow tasks and have the incident_task reference the incident created in the main workflow.
Main WF create an incident
Subflows create incident_tasks
I need to set the Incident on the incident_tasks.
How can I achieve this
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2019 10:09 AM
Hi there,
In short, you want to retrieve the sys_id of the just generated incident? And pass that into your subflows? Is that possbile: Yes.
First, after the gr.insert(), on your GlideRecord query to generate the incident, you have gr.getUniqueValue() available. This will be the incident sys_id. You can then add to a Run Script step something like:
workflow.scratchpad.incident_sysid = gr.getUniqueValue();
On the sub-workflow, you can add Inputs. Below an production example we have. You just need something like ${workflow.scratchpad.incident_sysid}
When dragging/dropping the sub-workflow, onto your main workflow canvas, the default value will already be set. Meaning: the incident sys_id.
Within your sub-workflow, you now have the availability of the incident sys_id! Within a Run script step you could now simply use:
workflow.scratchpad.incident_sysid
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2019 10:09 AM
Hi there,
In short, you want to retrieve the sys_id of the just generated incident? And pass that into your subflows? Is that possbile: Yes.
First, after the gr.insert(), on your GlideRecord query to generate the incident, you have gr.getUniqueValue() available. This will be the incident sys_id. You can then add to a Run Script step something like:
workflow.scratchpad.incident_sysid = gr.getUniqueValue();
On the sub-workflow, you can add Inputs. Below an production example we have. You just need something like ${workflow.scratchpad.incident_sysid}
When dragging/dropping the sub-workflow, onto your main workflow canvas, the default value will already be set. Meaning: the incident sys_id.
Within your sub-workflow, you now have the availability of the incident sys_id! Within a Run script step you could now simply use:
workflow.scratchpad.incident_sysid
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2019 10:16 AM
Thank you Mark, Since Both WF and Subflow are on the Requested Items table I do not have inputs.
DO I need to make my SubFlows on the incident_task table instead?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2019 10:18 AM
Yes and No 🙂
The inputs is just hidden on sc_req_item table. Actually, it does work! Simply, temporarily, switch to another table, like incident and the inputs are visible. Then add your inputs 🙂 And switch the table back.
(or just disable the ui policy)
A proven mechanism, we have this in our production environment.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2019 10:43 AM
I am not using a run script to create the incident, I am using the create task activity.
I am setting my workflow.scratchpad.inc = task.sys_id;
I create an input variable called Incident as a string and a default ${workflow.scratchpad.inc}
In my subflow I have a create task activity that I am using and trying to set the task.incident = workflow.scratchpad.inc
It works if I use 1 WF but I tried the above steps and it is not setting the incident tasks Incident when the task gets created.
SO WF has a create task activity on the incident table
workflow.scratchpad.inc = task.sys_id; I am capturing the Incident sysID
My Subflow input
Incident - string default ${workflow.scratchpad.inc}
My SubFlow Create task activity is on the incident_task table
I am setting task.incident = workflow.scratchpad.inc;
I am not able to get it working.
The incident does not get set with the task.
task.incident = workflow.scratchpad.inc;