Make a variable mandatory in RITM when state is "working Progress"

chanikya
Kilo Sage

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Chanikya,



Create a Client script on RITM table with script as



if(g_form.getValue('state') == "PASS CHOICE VALUE OF IN PROGRESS)


{


g_form.setMandatory('PASS ADDRESS FIELD NAME HERE',true);


}


View solution in original post

4 REPLIES 4

andymcdonald
Kilo Guru

you need a catalog client script that runs on change of your state variable.   if the state variable is the value of interest, set the address variable to read mandatory.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Chanikya,



Create a Client script on RITM table with script as



if(g_form.getValue('state') == "PASS CHOICE VALUE OF IN PROGRESS)


{


g_form.setMandatory('PASS ADDRESS FIELD NAME HERE',true);


}


Hi Pradeep,



your script is working fine in RITM level,



I have applied same script in LEGAL REQUEST table, but it is not working in legal table.




SCRIPT


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


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


          return;


    }


    if(g_form.getValue('state').toString() == '18')


    {


    g_form.setMandatory('address',true);


    }


else{


  g_form.setMandatory('address',false);


}


}



OR



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


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


          return;


    }


    if(g_form.getValue('state') == 18)


    {


    g_form.setMandatory('address',true);


    }


else{


  g_form.setMandatory('address',false);


}


}



find_real_file.png






find_real_file.png


andymcdonald
Kilo Guru

Here's a example, you would just need an if statement in the script to select the value that you're interested in...as has been pointed out above:



find_real_file.png