Checking a List Collector for a Value?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2012 03:34 AM
Hi All,
Need some help with scripting please.
I have a list collector with a long list of left bucket values. I also have a workflow in which I want to check for a chosen rightbucket option. If there's one particular option in the list of options chosen by the user, I have to send a second approval. That part I have working just fine. The part I'm having a problem with is checking the options chosen in the list collector for the single value I want. I've found lots of bits of code that I've tried to cobble together without success.
This is what I have. It's in an IF SCRIPT in the workflow so I can get a yes or no for the workflow...
function ifScript() {
var varName = current.variables.ctmsaccess_responsibilities;
var opp = 'd368d049f01210848484ae45a01accba';
var rightBucket = gel(varName + '_select_1');
var selectedOptions = rightBucket.options;
//Get an array of all option IDs
var selectedIDs = new Array();
var index = 0;
for(var i = 0; i < selectedOptions.length; i++){
selectedIDs[index] = i;
index++;
//check to see if the array contains the value
if (opp in index) {
return 'yes';
}
return 'no';
}
}
I need some guidance or a simpler way to do this, I have to get this finished asap.
Thanks!
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2012 09:08 AM
Because a List Collector stores the selected items as a comma-separated list of sys_ids, you can use the following to see if a sys_id exists in that list:
answer = ifScript();
function ifScript() {
if (current.variables.applications.toString().indexOf("82992eb60ad337024fbb6d06a866c636") >-1) {
return 'yes';
}
return 'no';
}
Take a look at the "Test Catalog Item" catalog item and workflow in demo08 for an example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2021 12:30 AM
how to search from list collector in a table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2021 09:17 PM
Sorry, but I do not understand the question

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-25-2012 09:35 AM
Wonderful, Jim. Thank you!