How round the value after two decimal point
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2019 01:11 AM
We have a filed in our catalog item name Price. If the enter value 10.98723 it should round to 10.99. How to do this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2019 01:15 AM
Hi there,
Multiple options for this.
One could be to add:
.toFixed(2)
Tested below in Background script:
var price = 10.98723;
gs.info(price.toFixed(2));
Result:
10.99
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2019 01:23 AM
Hello SNOW,
You might want to ensure it is a floating point number first.
var myHours = parseFloat(current.u_hours_worked);
myHours = myHours.toFixed(2);
Please mark as Correct Answer and Helpful, if applicable.
Thank You!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2019 01:30 AM
Tried this already.Not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2019 02:29 AM
Hii,
var getDec = current.YOUR_DECIMAL_FIELD.toFixed(2);
current.YOUR_DECIMAL_FIELD = getDec;
Go through the below link which will help you for controlling the decimal field values
https://www.servicenowguru.com/system-definition/controlling-decimal-field-places/
I hope this will helps you.
Please mark as Correct Answer and Helpful, if it helps you.
Thanks,
Pooja Yadav