<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: How to access variable set variables in flow designer in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/how-to-access-variable-set-variables-in-flow-designer/m-p/2899256#M1105079</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/702099"&gt;@SHALIKAS&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Interestingly there doesn't seem to be an OOTB way of accessing Variables from a Variable Set directly using the&amp;nbsp;"Flow Designer support for Service Catalog".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Steps to do this for a MVS (for a Variable Set just use an object, not Array.object:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;1. Create a custom Action:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;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).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;2. Create a Script Step:&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Set the input variable to the request item (number/sys ID). Now in the script you'll need to GlideRecord into the RITM&amp;nbsp;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.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;(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 &amp;lt; 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);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;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).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Tip: Remember to set outputs.NAME and not outputs.LABEL (easy mistake to make).&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;3. Set the Script Steps Output Variables:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV id="tinyMceEditor_69575b8a29f14bSandeepDutta_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;4.&amp;nbsp;Parsing your data back to your flow&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV id="tinyMceEditor_69575b8a29f14bSandeepDutta_1" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;5. (Optional) Accessing data in Flow when multi variable set used.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Apr 2024 14:08:56 GMT</pubDate>
    <dc:creator>Community Alums</dc:creator>
    <dc:date>2024-04-16T14:08:56Z</dc:date>
    <item>
      <title>How to access variable set variables in flow designer</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-access-variable-set-variables-in-flow-designer/m-p/2899229#M1105069</link>
      <description>&lt;P&gt;I have created a custom action to run a script. But I am not sure how to access the variable set variables here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SHALIKAS_0-1713275748569.png" style="width: 400px;"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/348180i26627A4B6E0F3FEB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SHALIKAS_0-1713275748569.png" alt="SHALIKAS_0-1713275748569.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Also I need to use this script in all the catalog items. So how can I do this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 13:56:33 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-access-variable-set-variables-in-flow-designer/m-p/2899229#M1105069</guid>
      <dc:creator>SHALIKAS</dc:creator>
      <dc:date>2024-04-16T13:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to access variable set variables in flow designer</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-access-variable-set-variables-in-flow-designer/m-p/2899256#M1105079</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/702099"&gt;@SHALIKAS&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Interestingly there doesn't seem to be an OOTB way of accessing Variables from a Variable Set directly using the&amp;nbsp;"Flow Designer support for Service Catalog".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Steps to do this for a MVS (for a Variable Set just use an object, not Array.object:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;1. Create a custom Action:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;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).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;2. Create a Script Step:&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Set the input variable to the request item (number/sys ID). Now in the script you'll need to GlideRecord into the RITM&amp;nbsp;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.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;(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 &amp;lt; 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);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;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).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Tip: Remember to set outputs.NAME and not outputs.LABEL (easy mistake to make).&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;3. Set the Script Steps Output Variables:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV id="tinyMceEditor_69575b8a29f14bSandeepDutta_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;4.&amp;nbsp;Parsing your data back to your flow&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;/P&gt;
&lt;DIV id="tinyMceEditor_69575b8a29f14bSandeepDutta_1" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;5. (Optional) Accessing data in Flow when multi variable set used.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 14:08:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-access-variable-set-variables-in-flow-designer/m-p/2899256#M1105079</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-04-16T14:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to access variable set variables in flow designer</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-access-variable-set-variables-in-flow-designer/m-p/2900421#M1105468</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/702099"&gt;@SHALIKAS&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 10:38:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-access-variable-set-variables-in-flow-designer/m-p/2900421#M1105468</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2024-04-17T10:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to access variable set variables in flow designer</title>
      <link>https://www.servicenow.com/community/developer-forum/how-to-access-variable-set-variables-in-flow-designer/m-p/3153473#M1172979</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/702099"&gt;@SHALIKAS&lt;/a&gt;&amp;nbsp;this is a very helpful post, it matches closely to what I am trying to achieve. Would you be able to elaborate a bit more on these steps copied below?&amp;nbsp; If you don't mind, could you post screenshots of how you configure the Action Input and Output. Thank you ! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;1. Create a custom Action:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;2. Create a Script Step:&lt;/STRONG&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Set the input variable to the request item (number/sys ID).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 12:19:48 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/how-to-access-variable-set-variables-in-flow-designer/m-p/3153473#M1172979</guid>
      <dc:creator>WayneH490346913</dc:creator>
      <dc:date>2025-01-20T12:19:48Z</dc:date>
    </item>
  </channel>
</rss>

