- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 05:49 AM
Hi everyone -
I need to check for a particular selection from a list collector in a Service Catalog item. In the workflow, I can get the values (which are comma delimited by default) like:
current.variables.list_collector.getDisplayValue()
What I need to do is when generating tasks, I need to create a task if a certain item is in the list collector. In the workflow, how can I parse the selections and look for a particular item?
Thanks,
Shane
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 06:21 AM
Hi,
Not tested, but in an "if" activity, you can try something like (or remove the toString):
var arrayUtil = new ArrayUtil();
var list = current.variables.list_collector.getDisplayValue().toSring();
var arrayList = list.split(",");
if (arrayUtil.contains(arrayList, "youritem")) {
answer="yes";
} else {
answer="no";
}
Best Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 06:09 AM
Hi,
There are several possibilities here, I think the easiest would be to do an "if" with as scripted condition that check if this item is in the list. (of if condition true, create task, if not, go to next step)
Best Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 06:13 AM
Oh, right, I understand that I just do not know the code to do so

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 06:21 AM
Hi,
Not tested, but in an "if" activity, you can try something like (or remove the toString):
var arrayUtil = new ArrayUtil();
var list = current.variables.list_collector.getDisplayValue().toSring();
var arrayList = list.split(",");
if (arrayUtil.contains(arrayList, "youritem")) {
answer="yes";
} else {
answer="no";
}
Best Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 06:59 AM
I have tried the following with your code:
var arrayUtil = new ArrayUtil();
var list = current.variables.list_collector.getDisplayValue();
var arrayList = list.split(",");
if (arrayUtil.contains(arrayList, "Item A") || arrayUtil.contains(arrayList, "Item B")) {
answer="yes";
} else {
answer="no";
}
I am selecting Item A as one of the selections in the list collector, but the code is returning result No...