Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to Limit the Number of decimal places to "two" for money field

lakshman nalla
Tera Contributor

hi 

 

i have a requirement, we have a field that field's value is auto populating we have to set limit to two decimal places to that value. please suggest.

 

 

thanks 

lakshman

1 ACCEPTED SOLUTION

Mohan Mallapu
Kilo Sage

Hi @lakshman nalla ,

What i understand based on your requirement, If the value of the field is 10.12455  and the expected output is 10.12

If the field value is auto-populating from the Client script or BR, You can restrict the value limit by using the toFixed() Javascript method.
var num = 10.1234;
var n = num.toFixed(2);

Output: 10.12
Referral Link : https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_tofixed 


Please mark my answer as helpful and the solution accepted if it serves the purpose.


 

View solution in original post

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @lakshman nalla 

 

https://docs.servicenow.com/bundle/vancouver-platform-administration/page/administer/currency/task/c...

LearnNGrowAtul_0-1704202943217.png

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Mohan Mallapu
Kilo Sage

Hi @lakshman nalla ,

What i understand based on your requirement, If the value of the field is 10.12455  and the expected output is 10.12

If the field value is auto-populating from the Client script or BR, You can restrict the value limit by using the toFixed() Javascript method.
var num = 10.1234;
var n = num.toFixed(2);

Output: 10.12
Referral Link : https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_tofixed 


Please mark my answer as helpful and the solution accepted if it serves the purpose.


 

Mike Adams1
Tera Contributor

This doesn't work