Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Clear Values from currency field based on true/false field

farci
Mega Expert

Hi Team,

I have been trying to remove/clear values from a currency field based on a true/false field on a form.

I used client script and even UI policy but it did not worked so far. Below is my client script, I tried even using SetValue but it didn't worked either.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == 'false') {
return;
}
if(g_form.getValue('invoice_calc')=='true'){
alert('Hi How are');
g_form.setValue('ia_ser_m',"");
g_form.clearValue('ia_ser_m');
g_form.clearValue('credit_app_invoice'); // Non currency field and clear values works here

alert('clear values');
g_form.setValue('ia_ser_m','');
alert('set values');
g_form.setReadOnly('ia_ser_m',false);
g_form.setValue('ia_ser_m_sp','');
alert('Last');
}
//Type appropriate comment here, and begin script below

}

Thank you for help in advance.

Regards,
Narmi

1 ACCEPTED SOLUTION

Yusuf5
Tera Expert

Have you tried this ?

g_form.setValue('amount', 'NULL');

View solution in original post

4 REPLIES 4

Wirasat
Tera Guru

I tried this and it works for me.

 

function onLoad() {
//Type appropriate comment here, and begin script below
g_form.clearValue('name');
g_form.setValue('amount', 0.00);

}

Yusuf5
Tera Expert

Have you tried this ?

g_form.setValue('amount', 'NULL');

Ujjawal Vishnoi
Mega Sage

Hi Farci,

As you mentioned 

g_form.setValue('ia_ser_m',"");
g_form.clearValue('ia_ser_m');

 

both code will work. Make sure your backend name (ia_ser_m) is correct.

 

Hope this helps

 

Regards

Ujjawal

farci
Mega Expert

Hi, 

 

Thank You for all your replies. g_form.setValue('amount', 'NULL'); works for Me.

 

Regards,
Narmi