How to Retreive data from Multi Selection Field Array

08 May '19, 11:49 PM
No Forum Badges

Hi everyone! Please help me out with this question.

I have one Multi selection Field inside a Form Component that has been divided in 12 different checkboxes, each corresponding a month from the year.  If I click in two of them (March and September) and send those checked items through a flow to a script component with an input called range in order to check what values I get from the checkboxes, I get the following:

--->Component Inputs: 

       Name                                                Value

--->range[scu8w.range]                           String[] (2 elements)

      [0]                                                       March

      [1]                                                       September


My question is is there any way, using the script component, to retreive those values (March and September) from the Multi Selection Field Array and transform them to numbers, something like this:

#input range

#output finalRange

def variable1

def variable2

def variable3

if (range[0] == "March")


          variable1 = "3"


if (range [1] == "September")


         variable2 = "9"


variable3 = variable1 + variable2


return["finalRange": variable3]


What I need is to get a range depending on those months and translate them to numbers to do something somewhere else. Like in the example above, if I check on March and September I would like to return 39. If I check January and April, I would like to return 14, If I check January and February the return value should be 12 and so on.... Any help would be massively appreciated. I've tried so many things but I can't get those months from the array.


Please help.


Thank you.

x 0
Answer Answer at this question and get points!
Forum Hero - Level 9

Hi Tomas,

first of all I suggest you to see this guide

In fact you can define the input and output parameters as single element or as array of elements. For example

#input String foo
#input String[] fooArray

Anyway you could change your current logic and implement an easier way. In fact the Multi Selection Field could return the id (number) of selected months instead of their names and you could manage the array already containing the desired items without other transformations executed by a Script.  In this case please refer to “Slot” definition and his uses

I hope this will help you

x 0
No Forum Badges

Thank you very much Alberto. Your help is greatly appreciated.

x 0
Answer at this question and get points!