workflows - branched IF conditions

mrswann
Kilo Guru

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,

find_real_file.png

find_real_file.png

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

10 REPLIES 10

I appreciate this approach - worked like a charm for me. 

The switch statement made the most sense but it only supported catalog variables instead of workflow variables. 

 

This did the trick for me - nice work. 

Kurt