Passing scratchpad sysID of task to subflow for Requested Items WF's

tricial
Giga Contributor

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

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

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}

find_real_file.png

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

LinkedIn

View solution in original post

9 REPLIES 9

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

LinkedIn

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

LinkedIn

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

 

tricial
Giga Contributor

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

Harsh Vardhan
Giga Patron