Changing Global Variables using Javascript | Community
Skip to main content
Niall_O_Donovan
New Participant
June 28, 2009
Question

Changing Global Variables using Javascript

  • June 28, 2009
  • 14 replies
  • 22921 views

Hi,

I have a project where I need to have lots of signature fields on a single form. I don't want to use a signatureField because this will increase the file size every time a signatureField is signed. Also client does not want digital signatures.

I set up three user variables (for both usernames and passwords), using Form/Properties/Variables.

I then set up a dialogue box on the click event of a button, which requests the username and password. If these match the global variables, then the associated textField is populated with the user's credentials. I got this to work OK.

The problems stated when I gave the user the ability to change their password. This would be an important, as the form would not need to come back to me to hardwire in the new password.

One of the global variables is "Pass1".The following script changed the value of the variable, but would not hold the change when the form was reopened:

     Pass1.value = AHSC02.strnewP;

".value" shouldn't work, but it did???

So I tried different versions of ".rawValue", but with no sucess:

     Pass1.rawValue = AHSC02.strnewP;

     form1.Pass1.rawValue = AHSC02.strnewP;

     form1.variables.Pass1.rawValue = AHSC02.strnewP;

Using ".rawValue" wouldn't change the password variable at all, even in the same session.

Source image file 175 not available

I would be very grateful if anyone had an idea as to how to change the global variable using Javascript, which will hold when the file is saved and reopened.

".value" works within the session, but doesn't hold the value on reopenning.

I am attaching a sample form, with three signing buttons/fields.

Username1 = Niall O'Donovan     Password = nod

Username2 = Marianne Barry     Password = mb

I have initially set up the "Niall O'Donovan" account with .rawValue and the "Marianne Barry" account with .value scripting.

I am wondering if this is considered a security issue by Adobe and therefore we are restricted from changing global variables using Javascript???

Thanks,

Niall

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

14 replies

Rui_Esteves
New Participant
June 29, 2009

Your Code works 99.9% you only have a typo in the Nial O'Donoval's name (in the names list of the signature JS and the global variable). Correcting that it changes the password.

What i wanted to say with the "the PDF must be able to save itself into file (form fill-in)." is that Dynamic PDF don't allow being saved with data (from data or global variables) by default, it has to be enabled,. You can either do it in Adobe Pro or using Livecycle Reader Extensions (both are payed solutions). If you do not, your code still works, but the changes won't be saved, so the next time the PDF is opened the password will be reseted to the default you puted in the pass[1-3] global field.

Niall_O_Donovan
New Participant
June 29, 2009

Thanks Rui,

I have been able to access the variables using ".value", as you suggested. However I have not been able to get the PDF XFA form to save the changes to the variables.

Can you elorabate on "the PDF must be able to save itself into file (form fill-in)."?

I am using LC Designer ES 8.2 and the users will be using Acrobat Professional and/or Acrobat Reader version 9. I have currently set the target version as 8.1. At the moment the form can be saved, but it does not appear to save the changes to the variables.

I appreciate the security risk (although I did not realise that variables were so accessible). The final form will be password protected (for opening in LC Designer) and the form is only intended for in-house use, it will not be going outside of the organisation.

Thanks,

Niall

Rui_Esteves
New Participant
June 29, 2009

The Global Variables don't have the rawValue attribute, but you can access their value from de the value attribute (myGlobalVar.value).

Also, this variables behave just like a normal textField, this is, in order to make your changes to its value persistente, the PDF must be able to save itself into file (form fill-in).

Also note that what you are doing is a huge security risk, because if i open you PDF with Acrobat Pro or run it through Reader extensions and enable export data feature, i'll be able to read (clear text) all the global variables.

Niall_O_Donovan
New Participant
June 28, 2009

Hi,

File is queued, so I have uploaded it onto Acrobat.com. It is available here https://share.acrobat.com/adc/document.do?docid=e65ec1c1-f5d2-40c1-88ea-ee6481f717c6

Thanks,

Niall