
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 06:26 AM
I think this should be an easy one for someone who knows.
I am setting up overtime claims. It will use 3 values to calculate an amount in currency. The values are overtime rate, hourly rate and amount of time (hours and minutes).
Not easy to get those values but, I got them. Now, I need to put the result of multiplying those values, back into a standard currency field (i.e. NOT an FX field).
My info message shows what I think is the correct value and my code matches this but the field remains empty. Any idea what I've done wrong:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var hours = g_form.getValue('u_hours_and_minutes');
var parts = hours.split(" ");
var dayPart = (parts.length > 1) ? Number(parts[0]) : 0;
var hourPart = Number(parts[parts.length-1].split(":")[0]);
var minutePart = Number(parts[parts.length-1].split(":")[1]);
minutePart = minutePart/60;
var decimalHours = hourPart + minutePart;
var rate = g_form.getValue('u_overtime_rate');
var hourly = g_form.getValue('u_hourly_rate').substring(4);
var currency = g_form.getValue('u_currency');
var amount = parseFloat(decimalHours) * parseFloat(rate) * parseFloat(hourly);
g_form.setValue('amount' + currency + ';' + amount);
g_form.addInfoMessage('Decimal Hours: ' + decimalHours);
g_form.addInfoMessage('Rate: ' + rate);
g_form.addInfoMessage('Hourly: ' + hourly);
g_form.addInfoMessage('Amount: ' + currency + ';' + amount);
}
The output for the last info statement looks like this:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 07:07 AM
It's me.... Hooray. I always think that there is a problem with our instance when I can't solve stuff like this.
Eagle eyed viewers will note that my setValue was wrong. Once I'd got the right field name in there, I was still trying to + that value into the field when, it should be ','.
Field updates and everyone is VERY happy.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 06:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 06:36 AM
No. I used .toFix(2) and it made no difference. My field still won't populate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 06:54 AM
Did a "back to basics" check and found that I was using the wrong field name for my setValue. However, I updated this to the correct one and it still doesn't work.
Also, tried read only and not read only versions of the field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-13-2022 07:07 AM
It's me.... Hooray. I always think that there is a problem with our instance when I can't solve stuff like this.
Eagle eyed viewers will note that my setValue was wrong. Once I'd got the right field name in there, I was still trying to + that value into the field when, it should be ','.
Field updates and everyone is VERY happy.