Bootstrap FreeKB - ServiceNow - Loop over an Array in Flow
ServiceNow - Loop over an Array in Flow

Updated:   |  ServiceNow articles

This assumes you are familiar with Flow Designer. If not, check out my article FreeKB - ServiceNow - Getting Started with Flows.

Let's say you have a Catalog that contains a Single Line Text variable. In this example, the Single Line Text variable is EAR.

 

In this scenario, the Catalog form would have an input form field named EAR. Let's say two values are entered in the input form field, foo and bar, and you want to loop over these values in the Form Designer Flow.

 

First we'll need a Flow Action that splits the values in the input form field into an array. In Studio let's select Create Application File > Flow > Action.

 

In the Action let's create two Input variables, both Mandatory (required).

  • input_string
  • delimiter

 

Next create a Script step that splits the elements using the delimiter.

 

And the script step outputs the result to an Array.String named result.

 

Last but not least, the result Array is returned as the output. I Save and Publish the Action.

 

Then in Flow Designer the Action can be used to split the elements in the input form into an array. In this example, the items are delimited using a comma.

 

And then I can loop through the results.

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 9602c4 in the box below so that we can be sure you are a human.