workflows - branched IF conditions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2016 03:14 AM
I previously had this working from the mini-lab https://community.servicenow.com/community/develop/blog/2015/10/18/mini-lab-workflows--playing-with-...
On a different project now and I want to employ the same again...
I am struggling to get the Condition to pay attention to the results in the script??
The script as follows:
activity = ifScript();
function ifScript() {
var result = {VALUE1:false,VALUE2:false, VALUE3:false, VALUE4:false};
if (VariableFieldValue == 'true') {
result.VALUE1 = true;
}
result.VALUE2 = true;
result.VALUE3 = 'true';
return result;
}
I have 4 conditions for the IF statement branches,
and so on...
I have also included some logs in the script and can see that the result.VALUEs are being updated, so it seems I am accessing the values incorrectly in the conditions to catch the output flows
when i had it without activity.result and just result.VALUE (no activity.) it was throwing an unbound or wrapped exception on result
- Labels:
-
Service Catalog
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2016 03:19 AM
You seem to be inconsistent in your boolean values.
Be careful how you are using true and 'true'. The first is a boolean and the second is a string. Either is valid as long as you are consistent. However if you set a variable like this:
var myVar = 'true';
This does not evaluate to true
if (myVar == true)
or if you set it to
myVar = 'false';
then THIS actually resolves to TRUE!
if (myVar)
because it is just checking for a non-null string value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2016 03:27 AM
Indeed and I apologise for confusion.
The first check about the variable, I believe comes in as a string. It is a checkbox display value?
The other inconsistencies are because I was trialling and erroring as part of a debug. Prior to that I was utilising pure boolean as activity.result.VALUEs , so if we assume all are set as boolean, and the condition is checking as boolean - what else could I be doing wrong?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2016 03:21 AM
Why not use a switch instead of 'If' block?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2016 03:28 AM
I need to be able to fire these simultaneously they are not mutually exclusive