- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 07:22 AM
Hi Everyone.
I have a requirement where there is a field called "services", and the type of field is list collector, i have given services table in that variable. there are two option: 1) mailbox 2) event queue. we have workflow, in which i used this list collector in "IF" block. this if should generate yes if "mailbox" is selected, it should also generate yes, if both the options are selected. How can i write a code for this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 08:56 AM
if you are using IF activity then it has a syntax and the answer variable should be set with yes/no
update your script as this
answer = ifScript();
function ifScript() {
var select = current.variables.u_services.toString();
var selectArray = select.split(',');
var opt1 = selectArray.indexOf('3460adbfdb7e1b00dd1662eb0b96198a') !== -1;
var opt2 = selectArray.indexOf('3860adbfdb7e1b00dd1662eb0b96198b') !== -1;
if (opt1) {
return 'yes';
} else {
return 'no';
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 10:35 AM - edited ‎07-07-2025 10:38 AM
Hello @Atchutaram
Please find the below script which I tried and tested for the requirement and it works for me.
Copy the Script as it is and it would work!!
answer = ifScript();
function ifScript() {
var select = current.variables.u_services.toString();
var selectArray = select.split(',');
var opt1 = (selectArray.indexOf('3460adbfdb7e1b00dd1662eb0b96198a') !== -1); //mailbox
var opt2 = (selectArray.indexOf('3860adbfdb7e1b00dd1662eb0b96198b') !== -1); //event queue
if (opt1||(opt1 && opt2)) {
return 'yes';
} else {
return 'no';
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Thanks and Regards,
Muskan Nema
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2025 12:25 AM
Hello @Atchutaram,
Greetings of the day!!
Just wanted to check if my reply answer was helpful to you and answers your question?
If my response helped, please mark it helpful and close the thread so that it benefits future readers.
Thanks, and Regards,
Muskan Nema
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2025 12:21 AM
@Atchutaram ,
I hope you are doing well!
Did my response help you?
Please let me know if you stuck somewhere.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Mohammad Danish