Acrobat Pro Javascript is unstable, working and not working
I've created a series of forms in Acrobat Pro that the Javascript works works only some of the time, or stops working, or works differently on different platforms.
Created and tested in Acrobat Pro on my computer, but also Acrobat Pro on MacBookPro, Windows 11, and using Acrobat Reader on all platforms. All software has Javascript enabled.
The simple form only has 1 recurring script attached to 8 similar fields to change the field color depending on the value of what's in the field. It works initially, then make any other changes to the form (no other Javascript) and save again... then the field scripts (sometimes) stop working when testing or opening it again to fill. Sometimes they don't work at all, even though nothing from those fields has changed.
I thought maybe saving a version that is Reader optimised (Save as Other -> Reader Extended PDF -> Enable more Tools) might work, but it's just as unstable as with Acrobat Pro.
The finished form is intended to be used as a template for a client and repair orders. So it will definitely need to be opened repeatedly and Saved As a new document each time (Buttons with Save As, Print, and Reset events are also on the form)
Question: how to save the PDF so that the Javascript always works and as many times it needs to be opened. And across Acrobat Pro and Reader with Javascript enabled, regardless of computer platform.
My Computer:
Apple M1 Max
Acrobat Build: 23.6.20380.0 (Latest Version)
Script attached to a text field->format:
// Custom Format Script
var MyGreen = ["RGB", 210/255, 255/255, 207/255];
var MyYellow = ["RGB", 255/255, 254/255, 176/255];
var MyOrange = ["RGB", 255/255, 206/255, 153/255];
var MyRed = ["RGB", 255/255, 178/255, 178/255];
var fieldValue = event.value;
if (fieldValue === "1") {
event.target.fillColor = MyGreen; // Light green
} else if (fieldValue === "2") {
event.target.fillColor = MyYellow; // Yellow
} else if (fieldValue === "3") {
event.target.fillColor = MyOrange; // because shade of orange
} else if (fieldValue === "4") {
event.target.fillColor = MyRed; // Red
} else {
// Reset the background color to default if not 1, 2, 3, or 4
event.target.fillColor = color.transparent;
}
Notes:
1. I have tried removing the "else" statement at the end. It works, but still unstable;
2. In a separate form being developed at the same time, I have the same main issue, but also Button scripts to spawn pages, page number scripts... sometimes work, sometimes don't, and again sometimes stop after reopening the same PDF.
Most grateful if anyone can help how I should save these forms so that the Javascript predictably works... ALL OF THE TIME..
