client script to reverse value

avani2
Giga Contributor

Hi,

I have written a client script which populates value of a readonly field based on value selected in another reference field on the form.

when I select a value in reference field , it is populating value..

What I need here is when I remove the value from that reference field , the value populated in readonly field should also get removed.

I have written a OnChange script on reference field.

Please help.....

1 ACCEPTED SOLUTION

Hi avani,



there is this line on the top.


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


          return;


    }


u need to change it to


if (isLoading) {


          return;


    }



and add below code.


if (newValue == '') {


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


          return;


    }



I hope this helps.



please mark helpful/correct based on impact.


View solution in original post

4 REPLIES 4

Kushagra Mehrot
Kilo Guru

Hi avani,



add something like this on your on change script:



if (newValue == '') {


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


          return;


    }



Thanks,


Kushagra


Hi Kushagra,



It is not working, I guess OnChange script is not able to detect when I am deleting the value of the field.


As it might not considered a change in value..


can you paste your code here ?


Hi avani,



there is this line on the top.


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


          return;


    }


u need to change it to


if (isLoading) {


          return;


    }



and add below code.


if (newValue == '') {


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


          return;


    }



I hope this helps.



please mark helpful/correct based on impact.