How to get check box value in run script

siddharth29
Mega Contributor

Hi team,

I am trying to design a work flow like the below screen shot.

Capture.PNG

and in run script i mentioned script like,

answer = ifScript();

function ifScript() {

  gs.log("@@@@hgst items"+current.variables.u_computer);

  if (current.variables.u_computer== "true") {

              return 'yes';

    }

    return 'no';

}

if   "computer check box is checked by user" then the request should go the "approval group as designed in workflow".... when i kept gs log also check box value is not getting in logs.

please guide me how to get check box value if it is checked request should go approval group

thank you.

1 ACCEPTED SOLUTION

Hi Prabhakar,



Please edit your previous post and remove the password.


I tried to reproduce on my instance and it didn't worked..Later on I realized that I am doing the same mistake...:P



You should not use "Run Script" for this and it should be the "If" activity with the script as below



answer = ifScript();


    function ifScript() {


    if (current.variables.u_computer == 'true') {


    return 'yes';


  }


    return 'no';


  }



P.S : I didn't login to your instance so please make the necessary modifications.



I hope this helps


View solution in original post

10 REPLIES 10

Can you share the screenshot of the variable pls


Hi Pradeep,



https://dev15063.service-now.com



ID-admin        


Password-Pr3@prabha



please go to maintain items "test" and the attached workflow



thanks


https://dev15063.service-now.com


Hi Prabhakar,



Please edit your previous post and remove the password.


I tried to reproduce on my instance and it didn't worked..Later on I realized that I am doing the same mistake...:P



You should not use "Run Script" for this and it should be the "If" activity with the script as below



answer = ifScript();


    function ifScript() {


    if (current.variables.u_computer == 'true') {


    return 'yes';


  }


    return 'no';


  }



P.S : I didn't login to your instance so please make the necessary modifications.



I hope this helps


Thank you vry much pradeep it is working and also i marked this as correct answer 🙂


Brian Dailey1
Kilo Sage

Hi Prabhakar,



Have you verified the variable's name?   Variables are not like regular table fields, I don't believe the "u_" prefix is required for variables that you've created.



Thanks,


-Brian