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

Not working unfortunately. I' guess I'll leave it as is  and tell the client it can't be done.

i knew it .. did you try on your pdi..

what version are you working

because on London dom has been disable you need to create one property the it will work.

 

find_real_file.png

 

i am able to clear it. i tested on my PDI

find_real_file.png

 

the message you will see on top

New client-scripts are run in strict mode, with direct DOM access disabled. Access to jQuery, prototype and the window object are likewise disabled. To disable this on a per-script basis, configure this form and add the "Isolate script" field. To disable this feature for all new globally-scoped client-side scripts set the system property "glide.script.block.client.globals" to false.

 

I have a little troubele following your screenshots.

yes I'm on London.

How do I get the form you're referring to?

 

create new property

NAme: glide.script.block.client.globals

type: true/false

value: false

 

then your script will work..