
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2020 12:10 AM
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?
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2020 12:35 AM
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:-
- In the editor, open and check out the workflow.
- In the title bar, click the menu icon and select Edit Inputs.
- In the Workflow Inputs window, click New.
- 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.
- Click Submit.
Please Mark Correct and Helpful
Thanks and Regards
Gaurav Shirsat

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2020 12:35 AM
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:-
- In the editor, open and check out the workflow.
- In the title bar, click the menu icon and select Edit Inputs.
- In the Workflow Inputs window, click New.
- 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.
- Click Submit.
Please Mark Correct and Helpful
Thanks and Regards
Gaurav Shirsat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2020 12:59 AM
Hi Howaza,
You can create an input variable in the subflow which is of type string and pass the sysid of ritm to this variable and do the gliderecord in the subflow and use any values of the ritm in the subflow.
Steps:
1. Create an input variable in the subflow which is of string type as shown below. It is available in the workflow properties as shown below:
2. In the parent workflow use this as the input parameter from the workflow activity as this field will get appear in the workflow activity.
Before that you have to store the sysid of the current record in the scratchpad variable as :
workflow.scratchpad.change_id= current.getUniqueValue();
And use this scratchpad variable in the workflow activity which is calling the subflow from the parent workflow as :
in the change input field you have to mention as : ${workflow.scratchpad.change_id}
3. In the subflow you can use the ritm values in anywhere using the workflow.variables.changeid
The changeid is the backend name of the input variable which you have created in the first step.
This will hold the sysid of the prarent record and you can do gliderecord to fetch the parent record any variables as :
var gr = new GlideRecord('sc_req_item');
gr.get(workflow.variables.changeid);
var number = gr.variables.request_for;
Now the gr object will give you all the details of the ritm record.
Please mark helpful and correct.
Thanks,
CB

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2020 02:23 AM
Hi,
Are you using Flow Designer or Workflows?
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2020 06:29 AM
I'm using Flow Designer.
I have several Service Catalogs. In my main flow, I'm trying to call subflow corresponding to each Service Catalog. I was thinking about passing Request Item Record to each subflow and processing service catalog specific actions in the subflow.