- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2016 09:29 AM
Hi,
I'm using a field called u_business_service_ci on a Change form that is a List type with a reference to the table cmdb_ci_service.
I'm trying to validate, in a workflow, if any of the values for that field have a 'true' value from the cmdb_ci_service.u_sox_snapshot field then to answer 'yes'. Basically, checking all of the selections in the field to see if they have the checkbox on any of them and, if so, then it will go a certain route.
This is where I'm at so far, to at least retrieve the values. Would I go about then setting an IF statement checking to see if there is a 'true' in that string? Not sure I'm going about this the right way.
answer = ifScript();
var list = current.u_business_service_ci.toString();
var listArr = list.split(',');
for (key in listArr) {
var bsci = new GlideRecord('cmdb_ci_service');
if (bsci.get(listArr[key])) {
answer.push(bsci.u_sox_snapshot + '');
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2016 09:33 AM
Hi Jon,
So the goal is to see if at least one record has u_sox_snapshot set to true? If so, return "yes"?
You are close. I don't know that you need to save the value of bsci.u_sox_snapshot since that's what you are checking, right? Also, your answer is calling ifScript(), but there's no function named that so...
answer = ifScript();
function ifScript() {
var result = false;
var list = current.u_business_service_ci.toString();
var listArr = list.split(',');
for (key in listArr) {
var bsci = new GlideRecord('cmdb_ci_service');
if (bsci.get(listArr[key])) {
if (bsci.u_sox_snapshot)
return true;
}
}
return result;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2016 09:33 AM
Hi Jon,
So the goal is to see if at least one record has u_sox_snapshot set to true? If so, return "yes"?
You are close. I don't know that you need to save the value of bsci.u_sox_snapshot since that's what you are checking, right? Also, your answer is calling ifScript(), but there's no function named that so...
answer = ifScript();
function ifScript() {
var result = false;
var list = current.u_business_service_ci.toString();
var listArr = list.split(',');
for (key in listArr) {
var bsci = new GlideRecord('cmdb_ci_service');
if (bsci.get(listArr[key])) {
if (bsci.u_sox_snapshot)
return true;
}
}
return result;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2016 09:51 AM
That was it... you're my hero! Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2016 09:52 AM
You're welcome. And I forgot the "This code is untested" disclaimer (and a trailing } it would seem.)
Glad you go it working.