- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2018 02:14 AM
Hello,
I have a list collector variable on a catalog form. In the workflow, i'm trying to create an IF script to check if the list collector values are empty or not. If the values are empty the workflow should not create a task. If any value is selected then the workflow should create a task.
I am currently using the script below:
//variable name = non_standard
answer = ifScript();
function ifScript() {
var nonstandardList = current.variables.non_standard.toString();
var arrayList = nonstandardList.split(",");
if (arrayList.length > 0) {
return 'yes';
} else {
return 'no';
}
}
Unfortunately this is not working, the workflow will read the script as true regardless of what values are present in the list collector, empty or not.
The variable looks like this:
if any values from the left are selected on right the workflow should create the task, if left empty the workflow should not create the task.
Any ideas would be greatly appreciated.
Thanks,
Alex
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2018 02:45 AM
Hey,
After doing this post, I tried one more method that actually worked and it looks like this:
answer = ifScript();
function ifScript() {
var list = current.variables.non_standard.toString();
var arrayList = list.split(",");
if(arrayList != ''){
return 'yes';
} else {
return 'no';
}
}
Thank you for your suggestion, hopefully both these scripts will help other people like me. 🙂
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2018 02:33 AM
Hi Alex,
Try this
answer = ifScript();
function ifScript() {
if (JSUtil.notNil(current.variables.non_standard)) {
return 'yes';
} else {
return 'no';
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2018 02:45 AM
Hey,
After doing this post, I tried one more method that actually worked and it looks like this:
answer = ifScript();
function ifScript() {
var list = current.variables.non_standard.toString();
var arrayList = list.split(",");
if(arrayList != ''){
return 'yes';
} else {
return 'no';
}
}
Thank you for your suggestion, hopefully both these scripts will help other people like me. 🙂
Alex