onLoad script to clear the default 0.00 from currency field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 06:24 AM
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!
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 06:44 AM
with out Dom manipulation that's not possible, and that's not a good approach to use dom manipulation to clear the 0.00

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 07:24 AM
if you still want to use dom then refer the script below.
var text = document.getElementById('incident.u_tesing_currency.display'); //u_tesing_currency it should be your field name
text.value = '';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 07:39 AM
This is script goes inside the onLoad script or is it a separate one?
thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 07:39 AM
it will be inside your onload script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 07:42 AM
function onLoad() {
if(g_form.isNewRecord()){
var text = document.getElementById('incident.currField.display');
text.value = '';
}
}