I would like to create currency field

Bird1
Mega Sage

Hello,

I would like to set this field to be currency format automatically. 

It means if I enter '10000', it will auto convert to 10,000.00. If I enter '1000000', it will auto convert to '1,000,000.00'. This field will not allow user to manually type comma , and it could support 2 decimal. 

The value cannot be exceed than 999,999,999.99.

 

Could anyone help?

 

find_real_file.png

9 REPLIES 9

Saiganeshraja
Kilo Sage
Kilo Sage

On Submit()-- Catalog script

var s = g_form.getValue("field_name"); // getting field name
var float1 = parseFloat(s). toFixed(2);// Two digits

g_form.setValue("field_name",float1); // Setting the formatted value

if(float1 >= your value)

{

return false; // Abort if value if greater

}

Mark correct and helpful

I tried to modify to 'on change' script. It could help to add the decimal automatically when I enter the value and press tab button but no comma.

 

find_real_file.png

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Not sure if it suits your requirement, though maybe you can use a Variable of type "Custom" and selecting Widget "Variable Currency".

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

It doesn't work for me. I cannot enter any value.

 

find_real_file.png