- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 05:19 AM - edited 12-06-2023 05:34 AM
Hi All, I have a requirement to copy the pay rate(string field) from caller field to wage field(currency field) and it should be truncated to two decimal places.
Example- if user's pay rate is 56.8867 then wage field should populate as $56.88
please kindly help
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 10:53 PM
Hi,
Try below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if (newValue === '') {
g_form.setValue('dollar_amount', 'USD;0.00');
return;
}
var grievant = g_form.getReference('employee_id', callBack);
function callback(grievant) {
var payRate = parseFloat(grievant.u_pay_rate_amount);
g_form.setValue('dollar_amount', 'USD;'+currValue);
var currArr = payRate.split('.');
var decPart = currArr[1];
if (decPart.length > 2) {
var x = Number(grievant.u_pay_rate_amount);
var currValue = "USD;" + Math.round(x * 100) / 100;
g_form.setValue('dollar_amount', currValue);
}
}
}
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 10:58 PM
Hello @Jyoti Tripathi
The above code is tested in my Personal Instance and got the expected output-
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Prashant Ahire
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 11:13 PM
@Prashant Ahire : But the amount got round off from 88 to 89
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 11:27 PM - edited 12-06-2023 11:27 PM
@Jyoti Tripathi
That is correct according to the mathematics -
The number is rounded up if the tenth digit equals or more than five. However, the number is rounded down if it is less than 5. If the digit on the tenth decimal value happens to be more than 5, then one is added to the whole number left to the decimal point
for your reference-
https://www.turito.com/learn/math/rounding-decimals
Please check and Mark Helpful and Correct if it really helps you.
Regards,
Prashant Ahire
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:28 AM
Hello @Jyoti Tripathi
Did this helped you?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2023 01:58 AM
@Prashant Ahire : I got your point but this is about payroll, it should not get round off.