How to pic the first value in list collector field type in Flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 05:16 AM
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.
Created a action to pic the the first value in list collector. But in Output variable it showing [object.ScopedGlideRecord]
Action script : outputs.variable = inputs.variable.toString().split(',')[0];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 05:35 AM
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 02:40 AM
Hi Valmik,
I am using this in script section in flow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 02:55 AM
Hi,
Replace below code with the code given by me
var name=i.split(',');
Replace above with
var name=i.toString().split(',');
Thanks,
Valmik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2022 04:40 AM