How to pass Requested Item Record to Subflow

Hitoshi Ozawa
Giga Sage
Giga Sage

Is if possbile to directly pass Requested Item Record to Subflow as a parameter or do I have to extract all the values in the main flow and then pass them to the Subflow parameter?

1 ACCEPTED SOLUTION

Gaurav Shirsat
Mega Sage

Hi Howza

Service Now Docs states:
Subflows on the Requested Item [sc_req_item] table in the Service Catalog cannot accept variables from parent workflows."

The variables are indeed available in the subworkflow (parent on sc_req_item, sub on sc_req_item). They are available in the workflow.variables object. 

To find them, use the following log statement in the subworkflow:

gs.log(JSON.stringify(workflow.variables), 'workflow.variables');

The variables are then available by using the toString() method on the variable attributes, e.g.workflow.variables.myvariable.toString(). If your variable is a reference field, it will have the suffix _reference in the variablename. E.g. workflow.variables.hostname_reference.toString() instead of workflow.variables.hostname.toString().

One More Approach:-You could also try to let the subworkflow run on global, then you have input variables.

This is How You Can Pass the Variable:-

  1. In the editor, open and check out the workflow.
  2. In the title bar, click the menu icon and select Edit Inputs.
  3. In the Workflow Inputs window, click New.
  4. Populate the record with the definition of the variable, including the column name, the label that is displayed to the user, and the type of field.
  5. Click Submit.
https://docs.servicenow.com/bundle/london-servicenow-platform/page/administer/workflow-activities/ta...

Please Mark Correct and Helpful

Thanks and Regards

Gaurav Shirsat

View solution in original post

11 REPLIES 11

HI,

This is easy, you just need to declare inputs to for your subflow. Then from main flow you can pass the whole GR to subflow as below:

This is an example.

 

Below is how to define inputs to Subflow to allow GlideRecord from main flow to subflw:


Thanks,
Ashutosh

MrMuhammad
Giga Sage

Hi Howaza,

You need to create input variables in your subflows that you want to flow from your parent flow. While calling subflow from Flow it will ask you to specify the subflow name and the input variables that is required by subflows. You can pass requested item only and extract all the variables in subflow. 

find_real_file.png

 

Please go through this link to step by step process of passing out of flows as input to subflows. 

Adding Subflow Inputs

 

Please mark this accepted and helpful if your question has been answered. Thanks!

Regards,
Muhammad

See screenshot below for reference. 

 

Input Variable (Requested Item)

find_real_file.png

 

 

Data Available in Subflow

find_real_file.png

Regards,
Muhammad

Shantharao
Kilo Sage

Hi,

if you are using normal workflow and Subflow activity, you can store current RITM object in workflow_gscratchpad object and pass it to the Subflow activity

 

Mark Correct if my response solves your issue and also mark 👍 Helpful if you find my answer helps you based on the impact.

Hitoshi Ozawa
Giga Sage
Giga Sage

Thank you all for prompt replies. I'm trying out the solution you've provided. I had to write over 100 knowledge base article for our system. Will get back.