- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2018 07:18 AM
I have what I feel should be an easy fix (at least in JavaScript outside of ServiceNow). I have a requirement of displaying a currency field with two decimal places no matter what the value is. When I edit the field client-side in a form and input a value that is just an integer, I need the value to display '.00' after the integer.
I am able to do this though onChange by changing ANOTHER field's value using .toFixed(2), but I don't know how to change the newValue (current value) through an onChange client script. I'm sure this is disabled because of potential looping issues.
How can I get a fixed two decimal format to be added to all user inputted values on the client side for a currency form field?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2018 06:06 AM
Hi Ankur,
Your answer was just a question, so I'm not sure how it could be correct. I found out a workaround that i'll share with the community. I ended up using jQuery on the Form Widget to add an onBlur function to all data-type="currency" fields in the form. I end up doing my currency formatting in that onBlur script and that seems to work properly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 10:55 PM
Hello @Ankur Bawiskar ,
I am setting a calculated float value in currency field. The value is calculated in script include which is called by onchange client script. When the total value exceeds 7 digits the value is shown with decimal point.
link to my question : https://www.servicenow.com/community/itsm-forum/currency-value-not-displaying-8-digit-total-sum/td-p...
would you please look into it and share your opinions?
Regards,
Harshada