I used this before with rain and it works in that Form. I copied the working script for rain and used it here.
I changed the fld- numbers to be for this form.
The calculations seem to be doing something unexpected.
Please tell me what is wrong?
If you get this to work, another question is how do I get the total sum from one record displayed in the next record?
In each record I want to show
Today’s hours
Yesterday’s total hours
Today Total hours (which is the sum of the above.
I like to see these so I know the math is working and I can easily check.
Attachments:
You must be
logged in to view attached files.
Hi Glen,
Set the return type of your Today & Previous script to number
! As text
, it concatenates the fields instead of adding them.
Here’s the yesterday’s hours script:
function yesterdays_hours() {
var records = form.getRecords();
var currentRecordIndex = records.indexOf(record);
if (currentRecordIndex > 0) {
var previousRecord = records[currentRecordIndex-1];
} else {
return 0;
}
var today_hours_id = 'fld-7ecb8ad8fe3a4b6db80ea939a60accb2';
var yesterday = previousRecord.getFieldValue(today_hours_id);
console.log("Yesterday: " + yesterday)
return yesterday;
}
yesterdays_hours();
I think I got it to work by using the above for one field and today for another and combined the 2 fields. Simplifies it with an additional field.
Thanks.