Skip to main content
January 30, 2019
Answered

InvalidSetError when trying to set value of field

  • January 30, 2019
  • 1 reply
  • 1034 views

Hello,

this is a really simple question but still I cannot see anyone with this problem.

I am only trying to set the value of a field using:

this.getField("myField").value = 3;

but I get an InvalidSetError.

However I can set the value if I use the importTextData function. So the field name is correct, it is writable but doesn't accept a value.

Thank you

This topic has been closed for replies.
Correct answer Thom Parker

that happens when you run this code in the console window:

this.getField("myField").value

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
January 30, 2019

that happens when you run this code in the console window:

this.getField("myField").value

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
January 30, 2019

If the field is empty, then nothing happens.

If there is a value in it, then it writes the value to the console.

Can this be caused by some sort of security or protection of the PDF file?

Thank you

try67
Community Expert
Community Expert
January 30, 2019

Yes, that's most likely the cause.