- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on ‎06-30-2020 02:17 AM
Hi all,
With the impending advent of Flow Designer becoming the new De Facto Tool for Workflows in ServiceNow I decided to utilise the tool for use with my customers Service Catalog. But was hit by a roadbloack:
How do I access Variables from a Multi/Variable Set in my current Flow?
Interestingly there doesn't seem to be an OOTB way of accessing Variables from a Variable Set directly using the "Flow Designer support for Service Catalog".
Steps to do this for a MVS (for a Variable Set just use an object, not Array.object:
1. Create a custom Action:
Feed the custom action the RITM that you'll be using in the flow (I've been forced to feed it the RITM number/Sys ID, as for some reason unknown to me you can't feed the flow a single record, there is only multi record select).
2. Create a Script Step:
Set the input variable to the request item (number/sys ID). Now in the script you'll need to GlideRecord into the RITM process the data into an Objects Array. In the below case I have looped through a multi variable set and set the OUTPUT variable to the newly created object.Array.
(function execute(inputs, outputs) {
// ... code ...
var ritm = new GlideRecord('sc_req_item');
ritm.get(inputs.sc_req_item);
var objectArray = [];
var fullSet = ritm.variables.[YOUR VARIABLE SET NAME];
for ( var i = 0 ; i < fullSet.getRowCount() ; i++){
var item = {};
item.hostType = fullSet[i].[VARIABLE NAME 1];
item.hostName = fullSet[i].[VARIABLE NAME 2];
item.hostOperatingName = fullSet[i].[VARIABLE NAME 3];
item.networkZone = fullSet[i].[VARIABLE NAME 4];
item.dataCenter = fullSet[i].[VARIABLE NAME 5];
item.componentName = fullSet[i].[VARIABLE NAME 6];
item.applicationImplementationLanguage = fullSet[i].[VARIABLE NAME 7];
item.languageVersion = fullSet[i].[VARIABLE NAME 8];
item.applicationServer = fullSet[i].[VARIABLE NAME 9];
item.lifeCycleStage = fullSet[i].[VARIABLE NAME 10];
item.brand = fullSet[i].[VARIABLE NAME 11];
objectArray.push(item);
}
outputs.objectarray = objectArray;
})(inputs, outputs);
In the above case I've had to loop through depending on the row count, this is used in the case of a multi variable set (as the number of loops can vary from RITM to RITM).
Tip: Remember to set outputs.NAME and not outputs.LABEL (easy mistake to make).
3. Set the Script Steps Output Variables:
You'll now need to set the output variable of the Script Step to the same structure of the object.Array you've created. Currently Flow Designer supports String, Integer, Date/Time, Choice, True/False and Object as outputs in your object. See below for my setup.
4. Parsing your data back to your flow
For this step you'll need to create a new object.Array output variable and drop the script steps output variable to the subflow output variable value:
5. (Optional) Accessing data in Flow when multi variable set used.
In the case of pulling data from a multi variable set you'll have to create a forEach loop in your Flow and loop through the object.Array to access the data as you'll have a variable number of objects in that Array. In the Case of a Variable Set you can just use an object output and not an Array.object.
Congratulations! You now have access to your data!
REQUEST:
If you find the article helpful, please mark the article as helpful and do remember to bookmark this article.
If you need any further advice on this topic feel free to contact me! (No promises, but i'll do my best to help!)
- 12,203 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks for posting this....but has anyone found any notes from ServiceNow as to why this isn't just OOTB in flow designer?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hey Jeff,
Couldn't tell you exactly why it wasn't an OOTB feature.
However, it looks like they'll be releasing an OOTB action in the Paris Release:
https://docs.servicenow.com/bundle/paris-servicenow-platform/page/administer/flow-designer/reference/get-cat-variables-flow-designer.html
Cheers,
Dal

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Sorry but when you say that you passing the flow the RITM/SYS_ID for a multi-record set, do you mean a multiple variable set? The reason that I'm asking is that getting a "'variables' is not defined" error and I have to think that it's in the requested item input. I'm setting up a request for multiple new hires, gathering their names, titles, hiring managers and so on through a MRVS and my hope is to us your guide as way to transfer in the data on to a workflow for deployment.
Thanks for any help and thanks also for the post!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I am seeing the same error Derek reports here
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I am seeing the same error Derek reports here

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
It OOTB in Paris
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Why not use the "Get Catalog Variables" action?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thanks Tomasz, understood. We're in the process of upgrading from O to Paris now, so doing testing of this.
Jeff

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Get Catalog Variables doesn't work for MRVS on pre-Paris instances.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
We are on Quebec and still cannot access variables within the MRVS

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
THANK YOU!!
This one line saved me: Tip: Remember to set outputs.NAME and not outputs.LABEL (easy mistake to make).
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Thank you the help
I have a Questions about Step5.
how to create a forEach loop in Flow and loop through the object.Array to access the data?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I have an Array.Object as an output variable but it just doesn't map to the script output.