
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 08:24 AM
Please could some assist with the following script im wanting to use in flow designer?
var aData = fd_data._6__look_up_records.records;
var aArr = [];
var msg = "This is a test";
if(!aArr.length){
while (aData.next()) {
aArr.push(aData.getDisplayValue());
}
return aArr.join(', ')
}
else{
return msg;
};
Following a lookup of records in the flow, I want to push the content of the array into the additional comments. So if the lookup returns items, they successfully post to the comments. But my else isnt working.
Probably something simple im not doing right, but equally, the flow script often throws me!!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 08:39 AM
Hi matt
Try this logic to return else part if there are no records.
var aData = fd_data._6__look_up_records.records;
var aArr = [];
var msg = "This is a test";
​while (aData.next()) {
aArr.push(aData.getDisplayValue());
}
if(aArr.length){
return aArr.join(', ');
}
else
return msg;
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 08:39 AM
Hi matt
Try this logic to return else part if there are no records.
var aData = fd_data._6__look_up_records.records;
var aArr = [];
var msg = "This is a test";
​while (aData.next()) {
aArr.push(aData.getDisplayValue());
}
if(aArr.length){
return aArr.join(', ');
}
else
return msg;
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP