Copy link to clipboard
Copied
I have run into an issue, with some of the Scripts, I have several pages, and each page has several text forms that the user can add a number into the field, at the bottom of the page the numbers are totaled into one field and the avg is placed into another. There are 10 pages, that follow this format. On page 11, I pull the avgs. from each page. Placing each of the avgs. in its field, then that number is multiplied, once the number is multiplied it becomes the "Weighted Value." All of the "Weighted Scores" are then added up, to a field named "GrandTotal," the "GrandTotal" is then divided by 100.
The problem I am running into is when I reopen the file I sometimes have to re-enter the Script to make it work. Also after I test the fields, I delete the number from one of the above fields, it zeros out in the results fields and weighted score field, but it leaves a number in the "results field" The code I am using is:
// Custom calculate script
// Get the field values as numbers
var numerator = +getField("GrandTotal").value;
var denominator = 100;
// Calculate and set this field value
if (denominator !== 0) {
event.value = numerator / denominator;
} else {
event.value = "";
}
Any help would be awesome.
Copy link to clipboard
Copied
In the "Grand total" you have also picked field "WEAPON_RESULT", uncheck it.
Copy link to clipboard
Copied
Change the field calculation order.
Copy link to clipboard
Copied
For the calculations, I am using the Value as the sum (+) of the following fields. Using the pick button I selected the fields, I wanted to add together. Is there a way to change the order of the calculations when they are selected that way?
Copy link to clipboard
Copied
There you can change the order:
Copy link to clipboard
Copied
Not related, but this part of your code is not needed:
if (denominator !== 0) {
You've defined the denominator to be 100. It can't be zero...
Copy link to clipboard
Copied
Thank you, it has been a few years since I did any coding at all.
Copy link to clipboard
Copied
I have also changed the Calculation Order so that they are in the order of the way they are in the pages of the document. The 9 fields do not add up to the proper number. I used 2 as my test number for each field. so the total should be 200 but it is being displayed as 202. I am not sure what is happening, any help would be awesome.
Copy link to clipboard
Copied
Can you share file?
Copy link to clipboard
Copied
I am attaching it here.
Copy link to clipboard
Copied
In the "Grand total" you have also picked field "WEAPON_RESULT", uncheck it.
Copy link to clipboard
Copied
Thank you, I was looking too close at it, but kept missing it I guess, couldn't see the forest from the trees.

