onLoad script to clear the default 0.00 from currency field

hamidouche
Kilo Expert

Hi,

I have a requirement to clear the default 0.00 in a currency field, preferrably when the form loads. This is my script and it's not working:

function onLoad() {

if(g_form.isNewRecord()){
g_form.setValue('currField, ' ');
// g_form.setValue('currField, ' NULL');  // not working either
}

If I put a fixed value:

g_form.setValue('currField, ' 2');  // it works

I don't get it! 

I already searched the other questions like this one :

https://community.servicenow.com/community?id=community_question&sys_id=2dd8da1edbd15300fc5b7a9e0f96193b

it's not working for me.

Thanks!

 

 

 

21 REPLIES 21

Mike Patel
Tera Sage

instead of g_form.setValue('currField, ' '); use g_form.clearValue('currField');

Alikutty A
Tera Sage

Hi,

Can you try g_form.clearValue('currField');  //currField should be your field name

hamidouche
Kilo Expert

No unfortunately I already tried that and it's not working

try 

g_form.setValue('currField', 'NULL')