Copy link to clipboard
Copied
I successfully created a form with multiple lines, each of which calculate the total hours to 1 decimal place between two Date&Time Fields (m/d/yy HH:MM) and then multiply the Hours by a Rate that is pulled from a dropdown box. The line total is then shown in the right most column.
I have a simple formula to totals all the lines at the bottome but after checking the calculation order, etc, it still will not update correctly. I have read all the posts regarding sum uodates but it seems everyone has a different approach and I still ca't get it to total correctly. I'll attach screen shots of the form and the scripts.
Any help would be greatly appreciated as I was only able to complete the form to this point using all the help I previously received. Again thanks to those who reached out and helped.
You need to fix calculation order and one of the fields was named wrong, "Total 11" should be "Total11"
I made changes check if it works now for you:
https://drive.google.com/uc?export=download&id=1jQNIgJ0k2tq8DskWSs3LHOnfjYTyagsa
Copy link to clipboard
Copied
If you get rid of the current script in the "TotalTrip" field, and just use the built-in SUM feature it calculates correctly.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Well, NesaNurani's answer complements what Bernd Alheit and JR Boulay are also suggesting.
In addition to those suggestions, this worked for me without the field name mispelling that NesaNurani pointed out.
But then, when I opened the console to check for errors, I also noticed the same "field is null" error as the screenshot provided by JR.
That makes sense with the incorrect spelling of a field object name.
The script will try to execute but then it stalls if a field name in the script doesn't match the actual name of the field object that the script is expecting to be referenced to.
By getting rid of the script and using the SUM built-in feature it didn't threw anymore errors and was calculating good.
I also noticed that you had all of the fields font size properties set to auto.
The TotalTrip text field was set with a font size of 12 pts.
Maybe this is relevant or not, but the font size was too big in contrast to the actual width and height of the text field object.
In the past, I've observed in my PDFs that if a font size is cut off (due to the dimensions of the text field itself), it will throw erronous results, specifically with date field objects that have custom calculating scripts in them (or used for other calculations accross that document).
So I changed all the fields' font size to 10pts including the TotalTrip field and that seemed to work for me.
Copy link to clipboard
Copied
Change the field calculation order.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
You need to fix calculation order and one of the fields was named wrong, "Total 11" should be "Total11"
I made changes check if it works now for you:
https://drive.google.com/uc?export=download&id=1jQNIgJ0k2tq8DskWSs3LHOnfjYTyagsa