clearValue based on change of another field

DebR
Kilo Explorer

Need a script to clear a field based on a change to another field. If the Software Maintenence [u_sa] field is changed from true to false, I want the Software Expiration Date [u_sa_expiration] field to be cleared. I realize this is pretty basic; I'm new to JavaScript and what I've tried hasn't worked.

5 REPLIES 5

ccajohnson
Kilo Sage

What you describe can be accomplished with an onChange client script:
Name: Clear Software Expiration onChange
Type: onChange
Field name: Software Maintenence
Script:



function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == 'true') {
return;
}
if (newValue == 'false') {
g_form.setValue('u_sa_expiration', '');
}
}


Let me know if you are still having difficulty, or have any questions.


I have tried your above script. I can't seem to get it to work. Any info would be helpful, as I need to do the same with Date Verified. Here's the info I am using and the script.


Name: Clear Room onChange of State


Type: onChange


Field: State


Script:


Clear Room When State Changes.JPG


I got mine working as well. I appreciate the tip.


Hello Christopher,



I have a similar issue, the difference being that I have actual choices rather than true or false. I did a very similar script but it doesn't work.


Do you see anything wrong or have any suggestions?



Thanks!



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


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


          return;


    }




    //Type appropriate comment here, and begin script below


      if (newValue == "Vendor payment term change") {  


              g_form.setValue('early_payment_value', '');  


      }  


  else if(newValue == "Early release of payment") {  


              g_form.setValue('annual_purchase', '');  


      }  



}