Set Variable via Catalog Client Script

au55iebum
Kilo Contributor

Hi all,

I am trying to set a variable base on the answers to other variable e.g. If variable question1 = Yes then set question2 to Yes

any anyone offer assistance

1 ACCEPTED SOLUTION
3 REPLIES 3

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Steven,



You can write an OnChange catalog client script on variable question 1 and set the value of question 2 as below


function onChange(control, oldValue, newValue, isLoading) {


    if (isLoading || newValue == '') {


          return;


    }


  if(newValue == 'yes')


  {


  g_form.setValue('pass variable name here', 'pass value here')


  }




    //Type appropriate comment here, and begin script below


   


}


Perfect. Simple and effective. I created a second script for "does not equal" (!=) to blank out the value too.