- 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 07:08 AM
Hi,
You've to put the sys_id of the "Item A" in place of the name.
or you can try, and check the name of your record in the if using a gliderecord:
var list = current.variables.list_collector.getDisplayValue();
var arrayList = list.split(",");
for (var i=0; i < arrayList.length; i++) {
}
Best Regards
Alexandre Herrero
EDIT: Try to display what is returned by current.variables.list_collector.getDisplayValue(); ---> so you will know what condition to do ---> for example: gs.log("Test: " + current.variables.list_collector.getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 07:32 AM
Hi Alexandre -
The return is the text display for the items, so example in the log it is in fact returning "Item A"
With that, I think your code you provided initially should work....
What am I missing?
Thanks,
Shane

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 08:14 AM
Hi,
Sometime it's just a problem of a "toString()" missing.
You can try to take the values like that: current.variables.list_collector.toString();
You should be able to make it work.
Best Regards
Alexandre
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 01:02 PM
Alexandre -
The code you used works great with the toString(), I just needed to be searching on the sys_id of those objects. Works fine now once I put that in the script.
Thank you,
Shane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2014 03:09 PM
If you are searching on the sys_id, there is no need to break it into an array. The simplest way to do it is:
answer = (function() {
if (current.variables.list_collector.toString().indexOf("sys id you are looking for") > -1) {
return "yes";
}
return "no";
})();
It will return "yes" if the sys_id is found in the comma-separated string of sys_ids that the list collector stores its values in.