NotAllowedError: removeField on Batch Sequence
I create forms for several different companies, and often the only difference is the header. Each header has several checkbox fields to select a particular branch for that company. To save time, I am working on a batch sequence to have the following functionality on one open file:
- *Add Background (this is the header, a pre-saved image)
- *Add Header/Footer (stamp with revision date)
- Add Checkbox Fields (via JS Execution)
- *Save Document with a prefix
- *Remove Old Background
- Remove Old Checkbox Fields (via JS)
- *Add New Background
- Add New Checkbox Fields (via JS)
- *Save Document with a prefix
*Lines marked with an asterisk are built into the action using pre-built action wizard tools... for now.
and so on... once I nail this down I will need it to go through about 5 iterations to end up with 5 saved files that have different headers. However, I am running into several problems.
- First and foremost, the code to remove the first set of checkboxes works perfectly in the console. No errors and removes all checkboxes, however it does return "undefined".
/* remove old checkboxes */
var oldBoxes = ["KPOR", "KBAN", "KLEB", "KLIM", "KCON", "KNAS", "KPAT", "KBUR", "KRUT"];
for (i = 0; i < oldBoxes.length; i++) {
this.removeField(oldBoxes);
}
When I try to execute the same code in the batch sequence, all but the last checkbox "KRUT" are removed, and I get a NotAllowedError:
NotAllowedError: Security settings prevent access to this property or method.
Doc.removeField:4:Batch undefined:Exec
I thought maybe this was due to the fact that the file was saved with a different name prior to removing fields, but removing the save function from the batch sequence produces the same result. Could the "undefined" that is returned when executed in the console have something to do with this?
- Ultimately, I would like for each iteration of the sequence to "Save As" instead of just saving each file. How it currently works (saving with a prefix) means that the next prefix is added to the beginning of the last file name (i.e. PFIX2_PFIX1_MyDoc.pdf) and I want to avoid that. It would also be awesome if I could save the root file name with both a pre-programmed prefix and a suffix of a revision date (i.e. _01.20.18). I have no experience with saving documents via JS (but I learn quickly) so any advice to get me started would be greatly appreciated!
FYI I am using Acrobat Pro DC on Mac OS 10.13.1. I am the only one who will need to use this sequence on my own computer.
THANK YOU!
