Copy link to clipboard
Copied
Dear Adobe Community,
I made a form with calculations under text field properties.
(They are all basic algebra )
1 is a custom calculation script, and the other 2 are simplified field notations (basic addition)
The calculation scripts are simply not always saving. If I make a new PDF off the old one - and save it w/a new name - while most field properties remain - the calculation scripts do not always save. Sometimes they do, sometimes they dont.
Even more bizzare - I have the PDF open now. The calculations are there. I close it (w/o saving), reopen it - and 1 of the calculatins is gone. Then i do the same thing, this time A DIFFERENT calculations is gone.
Really pulling my hair out.
Please help...thank you!
Here are the calculations:
(function () {
// Get the values of the text fields, as numbers
var v1 = +getField("FillText13").value;
var v2 = +getField("FillText14").value;
// Set this field's value based on the state of the check box named "CB"
if (getField("FillText16").value !== "Off") {
event.value = v1 - v2;
} else {
event.value = v1;
}
})();
(function () {
var sStart = getField("FillText40").valueAsString;
var sEnd = getField("FillText46").valueAsString;
var dStart, dEnd, diff;
if(sStart && sEnd) {
dStart = util.scand("m/d/yy", sStart);
dEnd = util.scand("m/d/yy", sEnd);
diff = dEnd.getTime() - dStart.getTime();
event.value = Math.floor(diff / 864e5) / 30;
} else {
event.value = "";
}
})();
FillText16 + FillText17 + FillText25 + FillText26 + FillText33
FillText27 * .10 / 12 * xy
Copy link to clipboard
Copied
Are you using the native JS editor or an external editor?
Copy link to clipboard
Copied
I am having a similar issue. I click on the edit button to add my script, enter the script, hit okay and not only is it not saving my script to the display area, but also moves the radio button to "Value is not calculated"
Very frustrating.
Script I am using:
event.value = getField("A-OG-CDA-SAVE 001").value * getField("B-WGHT-CDA-SAVE 001").value;
Copy link to clipboard
Copied
Platform? Acrobat version number? Using external editor or not?
We can't help you without details.
Copy link to clipboard
Copied
Windows 10, Acrobat Pro DC Version 2015.023.20056, not using an external editor.
Copy link to clipboard
Copied
Recorded the problem on my phone and uploaded to YouTube. I have been making forms for years and never had this issue before. Tested the other calculation fields as well get the same result of the radio button defaulting to "Value is not calculated"
Copy link to clipboard
Copied
Wow!!!! That video was incredibly helpful... unfortunately, I can't reproduce the problem. I'm going to guess that either the field you're editing is corrupt or one of it's input fields is corrupt.
Copy link to clipboard
Copied
Thanks for your quick responses and attention Joel and Try67.
I was afraid there might be an underlying issue with the export from InDesign. I'll keep trying and see what I can find out. Deleting 174 fields and recreating them makes me want to cry.
Copy link to clipboard
Copied
Ah, you created the fields in ID... That might explain it. I've encountered a lot of problems with these fields and always recommend to people to only do the layout in ID and create the fields themselves in Acrobat. Try doing a test with this one field by deleting it, saving the file, closing it, reopening it and then adding the field again (in Acrobat!) and seeing if the calculation works then.
This is a major bug of InDesign and Adobe really should have solved it a long time ago...
Copy link to clipboard
Copied
Wait... the fields were added to the PDF by InDesign? InDesign is great for creating interactive PDF when it's creating the final version. Without going into detail as to why, adding form fields via InDesign just isn't something I'd do if your intention is to further edit them in Acrobat.
I'm not going to elaborate. Just... don't. SMH No.
J-
Copy link to clipboard
Copied
LOL. Since I am designing the form in InDesign I create text fields as well because its faster than drawing them in Acrobat and also I'm OCD and it looks uniform and better from InDesign.
I'm not that good at scripting so before I was selecting fields using Acrobat's "Value is the [Product] of the following fields:" area, but after having the same issue from my video I looked up scripts to try that. Here is the work-flow if you were remotely curious:
Since you can't choose further field options in ID once I export to PDF I change all the fields to number format, then apply the calculations. In this case, I was doing it the hard way and creating a hidden field containing a predetermined weight, then I create a second hidden field that calculated a quantity field with the hidden weight field. Lastly, a field at the top of each page of the form adds all the calculated hidden fields to show a total weight for the form.
I'm going to try to create the fields manually in Acrobat, other than the quantity field, and see if this will help remedy the issues with the calculate tab as Try67 suggested. If it doesn't then I'll go to manually drawing all the fields and go from there. I haven't had issues until today with ID > PDF and I have been doing it for 7+ years. (the process for pre version 2015 was much more head shaking but still quicker work-flow wise)
Copy link to clipboard
Copied
Ok good - I was afraid you were going to say Acrobat 9 or something... I live and breath inside the JavaScript editor in DC and I'm not having any trouble with scripts not saving. In addition to what try67 suggested, try adding "this." to your "getField" method... as in...
this.getField("A-OG-CDA-SAVE 001").value
It's possible that the JavaScript verifier isn't liking your shorthand.
J-
Copy link to clipboard
Copied
Try deleting the field and then re-creating it.
If that doesn't work you can always apply the code using a script from the JS Console, like this:
this.getField("FieldName").setAction("Calculate", "event.value = getField(\"A-OG-CDA-SAVE 001\").value * getField(\"B-WGHT-CDA-SAVE 001\").value;");
Copy link to clipboard
Copied
Hi.
There are some tips in Acrobat to not draw fields one by one.
In Edition mode, right-clic on any form field and choose "Duplicate…" or "Create multiple…"
Copy link to clipboard
Copied
And of course one should always use the Fields Detection Wizard. It usually produces decent enough results, as a starting point...
Copy link to clipboard
Copied
It usually produces decent enough results, as a starting point...
No comment.
Copy link to clipboard
Copied
Make sure you're signed in to your Adobe account.
Copy link to clipboard
Copied
Alright well, 5 year old post, I know, but I ahve been having the exact same issue, and it has driven me absolutely crazy. I look at a field one minute and the script is there, then I do something else in another tab, come back, and its gone. Also have the same thing with opening a file and different fields are missing each time.
Anyways, for the sake of posterity im posting how I think I might have solved the problem here, for anyone like me whos losing their minds over this. All I did was click the "locked" checkbox in the properties tab, and none of them have dissapeared again so far. It sounds self explanatory when I say it that way, but It makes no sense to me why you should have to lock the properties in order to prevent a script from deleting itself. Its absolutely silly, and in no place in all the official Adobe literature ive dug though on the subject does it ever say that you have to do that. This issue has clearly been around for like at least 5 years now and its no small issue. It completely breaks PDFs, yet somehow it hasnt been fixed.
Copy link to clipboard
Copied
Worthless company... I am having the issue I put the code in and when I hit OK it goes back up to "value is not calculated" not even giving me the chance to lock it.
Copy link to clipboard
Copied
Does you code contain the string "AF", by any chance?
Copy link to clipboard
Copied
2024 and still the same problem.
I have to keep old versions of my forms so I can copy and paste when the scripts disappear.
Copy link to clipboard
Copied
Not sure, but looks like if you have the javascript window on on the form window (especially on the different screen) it will not save the java code.
Copy link to clipboard
Copied
Hello!
If you're encountering issues in Adobe Acrobat Pro where form field calculations or JavaScript scripts are not saving or are disappearing, consider the following steps to resolve the problem:
Recreate the Form Field: Delete the problematic field: In Acrobat, go to Tools
> Prepare Form
. Select the field, right-click, and choose Delete
. Save and close the document. Reopen the document and recreate the field: Use the Prepare Form
tool to add a new field. Assign a unique name to the new field. Re-enter the calculation script or set the desired properties.
Use Native Editor: Ensure you are using the native JavaScript editor within Acrobat, not an external editor. Ensure Adobe Acrobat Pro is updated to the latest version.
To learn more, see this article: https://adobe.ly/4iTROO7
Thanks,
Anand Sri.
Copy link to clipboard
Copied
[MOVED TO THE ACROBAT DISCUSSIONS]