Client Scripts: clearing currency field

yundlu316
Kilo Guru

We have anonChange client script that does a bunch of checks on a currency field (i.e. can't be above $5,000, needs to be multiples of $25, etc.)  For each of these, if a user puts in a number that triggers one of those checks, we throw up an error message and we want to clear the field.  

Below is a snippet of our code:

find_real_file.png

The issue we're running into is clearing the currency field.  We tried clearValue (above), which does absolutely nothing.  In other community posts, we've also tried the following:

g_form.setValue('u_award_cash_amount', 'NULL');
g_form.setValue('u_award_cash_amount', '0.00');

Both work in setting the value back to 0.00, however afterwards, it doesn't let the user edit the amount.  It basically remains 0.00 until you refresh the page and start over.  We've looked everywhere and cannot find anything on clearing a currency field; is this even possible?

11 REPLIES 11

Ben81
Tera Guru

Hello !

Have you tried g_form.setDisplayValue("u_award_cash_amount","USD;00");

Additionally, please have a look here: https://docs.servicenow.com/bundle/madrid-platform-administration/page/administer/currency/concept/l...

Hope it helps,

Ben

Fawad3
Tera Contributor

Do this
g_form.setValue("u_award_cash_amount","USD;00");

Nicole_k
Kilo Expert

Run an alert just to check the format or what is being returned. As per the previous comment the currency field will more often than not contain the currency short desc.

alert(u_award_cash_amount);

Hi yes, it does return as "USD;45" for example, but setting the display value to 0 still makes it un-editable afterwards.