If script to check if List Collector variable is empty
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2018 02:19 AM
Hello All,
I have created an if condition in my workflow script to check of a list collector variable is empty but it seems to be returning 'yes' whether the collector is empty or not.
This is the script:
answer = ifScript();
function ifScript() {
var AdditionalApps = current.variables.additional_apps.toString(); //convert the variable list to string
var arrayList = AdditionalApps.split(",");
if (arrayList.length > 0) {
return 'yes';
} else {
return 'no';
}
}
Could anyone shed any light on why this might be happening?
Labels:
- Labels:
-
Scripting and Coding
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2018 02:55 AM
Hi,
If you try by printing the length of arra, it will return 1. Therefore it is failing.
Rather than this try by checking if the value "current.variables.additional_apps.toString()" is equal to NULL.
Thanks,
Prateek Gupta