- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hi Team ,
I am trying to imply an workflow where it should runs events when , it met conditions like Lost item is either mifi device, byod device, issued mobile or issued surface device , or all of them or any of these combination basically , so however , In this case I tried both the ways , it's not working , the condition works when only one of these option is selected but when more than 1 option selected workflow doesn't work .
Please Suggest me further how I can achieve it .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
please share script here and not screenshot.
did you give correct variable name and correct record sysIds?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Glad to know that my script worked.
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
a month ago - last edited a month ago
Based in your screenshots I can’t see the item, it’s like “select item”
My you try your if condition via script
Selected true in “advanced” box and do some like this:
answer = checkVar();
function checkVar() {
// Get the variable value as a string (ServiceNow list collector may return a comma-separated string)
var variableValue = current.variables.VariableName; // e.g., "option_1,option_3,option_5"
if (!variableValue) {
return "no";
}
// Split the string into an array
var selectedOptions = variableValue.split(',');
// Initialize flags
var hasOption1 = false;
var hasOption5 = false;
// Loop through each selected option
selectedOptions.forEach(function(option) {
if (option.trim() === "option_1") {
hasOption1 = true;
} else if (option.trim() === "option_5") {
hasOption5 = true;
}
});
// Return "yes" only if both option_1 and option_5 are selected
if (hasOption1 && hasOption5) {
return "yes";
} else {
return "no";
}
}
}