Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Workflow Run Script Conditions Not Working ...

vkiran
Mega Expert

Hi Folks,

I have run into a issue with Workflow Run Script Conditions. The Conditions are not working.

find_real_file.png

Run Script Code

answer = ifScript();  

 

function ifScript() {  

var ftest = workflow.scratchpad.cait;

      if (ftest == '3')

{

      return 3;  

}  

if(ftest == '4')

{

      return 4;  

}

if(ftest == '12')

{

return 12;

}

}

I need the activity.result output based on the code conditions and i'm passing the value from scratchpad variable. Any help is appreciated.

1 ACCEPTED SOLUTION

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

change the first line to activity.result = ifScript() and you should be good.


View solution in original post

3 REPLIES 3

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

change the first line to activity.result = ifScript() and you should be good.


sachin_namjoshi
Kilo Patron
Kilo Patron

Hi Venkat,



How did you defined cait variable



The workflow scratchpad can store multiple data types, including:



Regards,


Sachin


Gowrisankar Sat
Tera Guru

// This script needs to set answer to 'yes' or 'no' to indicate the state of the activity.


//


// For example,


//



workflow.scratchpad.result = ifScript();  


 


function ifScript() {  


      var result = {thr:false, fou:false, twe:false, none:false};  


 


      if (JSUtil.notNil(workflow.scratchpad.deployedBy)) {  


              if (workflow.scratchpad.cait == '3') {  


                      result.thr = true;  


              }  


              if (workflow.scratchpad.cait == '4') {  


                      result.fou= true;  


              }  


              if (workflow.scratchpad.cait == '12') {  


                      result.twe = true;  


              }  


      }  


 


      if (!(result.twe || result.fou || result.thr)) {  


              result.none = true;  


      }  


      return result;  


}  



Add this below code in condition field of if condition blocks:



workflow.scratchpad.result.twe == true