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

Nice.

Thanks,
Ashutosh

Hitoshi Ozawa
Giga Sage
Giga Sage

Thanks all, got it working.