Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to pic the first value in list collector field type in Flow designer

Munna1
Tera Contributor

Hi All,

How can I pic the first value in list collector field in Flow designer.

I have one Model, it has multiple model categories. Here for each model category there is a group to send for approval.

If am updating any field in this model it has to send an approval to first model category's group of this model.

Here How can I achieve this. 

If I am trying to get the value of the field by look up record . It picking all model categories and showing an error.find_real_file.png

Created a action to pic the the first value in list collector. But in Output variable it showing [object.ScopedGlideRecord]

find_real_file.png

Action script :   outputs.variable = inputs.variable.toString().split(',')[0];

12 REPLIES 12

Valmik Patil1
Kilo Sage

Hi,

In script part of action you can parse the object in array using below script

and output only first value of array in action

Please refer below code

var list = inputs.param1.toString();

var array = list.split(',');

for (var i=0; i < array.length; i++) {

      gs.log("Your values are: " + array[i]); // here you will find each record

}

OR

There is separate article written by @Ankur Bawiskar  you can refer that as well

https://community.servicenow.com/community?id=community_blog&sys_id=e244e902dbcc2010fb4ae15b8a9619c3

Please don't forgot to mark it as helpful if it helps you

Please let me know if you need any other help.

Thank,

Valmik

 

Hi Valmik,

I am using this in script section in flow.

var i=fd_data._1__get_catalog_variables.current_model_category;
var name=i.split(',');
for(var n=0 ; n<name.length ; n++ )
{
var value = name[n];
}
var query;
query="sys_id="+value;
return query;
 
But it showing this error: Cannot find function split in object [object GlideRecord].

Hi,

Replace below code with the code given by me 

var name=i.split(',');

Replace above with

var name=i.toString().split(',');

Thanks,

Valmik

But it's not picking any sys_id from the list collector

showing Like this : find_real_file.png.