- 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:57 AM
I actually don't know how to get the sys_id when you use the create task activity. With the Run Script activity, it should work (proven mechanism).
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 11:00 AM
Just a really quick search and quick test on my PDI:
task.setNewGuid()
does work to get the sys_id of the created record with create task activity.
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 11:40 AM
Mark,
I am getting the sysID from the Incident but I am having a problem getting it to the subflow
I created an input called task.incident
Im still having trouble getting the incident passed to tthe subflow tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2019 12:00 PM
Hey Mark,
Ok I got it working 🙂
I had to add this to my Subflow task
task.incident = workflow.inputs.u_task_main_flow;
Thank you so much for your help and patience !!
Have a great Holiday
Tricia

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2019 10:14 AM
adding official doc link. it has explained very well.