[Help] OnChange Field Value change script

Jordan14
Giga Expert

Hello,

I've been tasked with another request to create an OnChange script which once something is inputted into a different field it triggers

the OnChange script and changes the value in a different field.

For example,

State: 1

name : <nothing>

after changes:

State: 2

name: Jordan Thompson

From this, you can see a name was imputted and the state changed from "1" to "2".

Thanks,

Jordan

1 ACCEPTED SOLUTION

Hi Jordan,



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


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


return;


}



//Type appropriate comment here, and begin script below


var check= g_form.getValue('state');


var ad=g_form.getValue('assigned_to');


if(check=='2' && ad != '')     //assumed "root couse required" value is 2. you can check this value at your end from choice .


{


g_form.setValue('state','<your state value that you want to set>');


}



}



Let me know if it does not help


View solution in original post

8 REPLIES 8

Hello Harsh,



Looking at the screenshot below you can see the state field and the assigned too field.



What I want the script to do is:



If "Root Cause Required" is selected and a name is selected in the assigned too field, I want this to trigger a script where it changes the state field to "Root Cause Analysis".



PMThep.png



Thanks,


Jordan


Hi Jordan,



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


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


return;


}



//Type appropriate comment here, and begin script below


var check= g_form.getValue('state');


var ad=g_form.getValue('assigned_to');


if(check=='2' && ad != '')     //assumed "root couse required" value is 2. you can check this value at your end from choice .


{


g_form.setValue('state','<your state value that you want to set>');


}



}



Let me know if it does not help


Big Thanks,



This worked great.


Michael Fry1
Kilo Patron

This happens today out of the box. Initial state is New, but once someone is assigned, the State changes to In Progress.