Custom format script
Copy link to clipboard
Copied
How correctly set custom format script for newly created text field?
I tried f.setAction("Format", "my_script"). No error shows after creating my text field, but nothing appears in custom format field box for that field. I cannot figure out what is missing. Cannot find anything relevant online. Script itself works fine. Please help. Thank you very much in advance.
Copy link to clipboard
Copied
f is undefined.
Try:
this.getField("FIELD-NAME").setAction("Format", "my_script");
Acrobate du PDF, InDesigner et Photoshopographe
Copy link to clipboard
Copied
Of course f is defined, I just haven't shown that. All code works, I just cannot find details/instructions about that setAction("Format", ...) line.
In other place I have f.setAction("Keyword", "my_script") and it is working just fine.
Copy link to clipboard
Copied
excuse me, "Keystroke"
Copy link to clipboard
Copied
What's the actual code you used for the format script itself?
Copy link to clipboard
Copied
All details/instructions are here in the SDK:
Acrobate du PDF, InDesigner et Photoshopographe
Copy link to clipboard
Copied
How does you test the script?
Copy link to clipboard
Copied
Just to be clearer: When creating a new text field, I want to add custom format script. I can easily do that when field already exist using Acrobat custom format option. However, when I tried to do that using js f.setAction("Format", "my_script") like shown in the manual, there is no action. This line is just ignored and nothing appear in my new text field property custom format window. I cannot understand why is that.
May be Thom Parker knows why if he is still there :).
Copy link to clipboard
Copied
> I can easily do that when field already exist using Acrobat custom format option.
What does you enter there?
Copy link to clipboard
Copied
I can enter there any JS, such as getField("Test").value = 1 and it works. But using setAction("Format", "getField("Test").value = 1") doesn't work. Very strange.
Copy link to clipboard
Copied
Check the Javascript console for errors.
You must use \" in text strings, not only "
Copy link to clipboard
Copied
Is your field name correctly in f variable?
Can you post full script you use?
Copy link to clipboard
Copied
Thank you guys, of course that was my fault.
I just have two f. text fields and all the time tried to apply my script to the wrong field.
Everything works like intended 🙂

