Skip to Content
Author's profile photo Prajesh Desai

Manipulate (reference) fields in script for adobe forms

Lots of developer getting confused in manipulating one field value on another field. I also suffer from this when i started learning adobe forms and adobe script. so now i found something that auto reference the fields using below trick.

Also go through To insert object reference syntax automatically: Adobe Forms

Example:

Now lets say i’m having below hierarchy,

Untitled.png

Now i want to write script to fill Sub2 = Sub1 + 10.

Step 1) Click on txtSub2.

Untitled.png

Step 2) Then click in script editor event, where you want to write code to fill Sub2.

Untitled.png

   Now press Ctrl key and drag mouse pointer on field in Design View, pointer icon will change to \/ icon. (v shape icon)

Untitled.png

Step 3) Now when your mouse pointer is change, do mouse click, and reference of field will auto paste in script editor.

Untitled.png

this way you can easily manipulate fileds in adobe forms.

Step 4). Now write below script,

Untitled.png

Output,

Untitled.png

Now, for Total i want Sub1 + Sub2,

Same as i expalined above,

     > select Sub1 or Sub2 (one by one),

     > click in script editor event,

     > press Ctrl key,

     > drag mouse pointer on respective field and

     > do mouse click

Your final script will be,

Untitled.png

For Mass Total, (sub1 + sub2 + total)

Untitled.png

Final Output,

Untitled.png

We get what we want, this may confused you, drop your query below if any.

Hope this helps.

Assigned Tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Christopher Solomon
      Christopher Solomon

      Nice and to the point! Just a minor point to add....as a matter of good practice, when you are referencing another field on your form in script outside of your current field (ie."this"), it is good to do the following...

      this.rawValue = xfa.resolveNode(somefieldname.rawValue);

      xfa.resolveNode will always try to find the named node even if you do not give the exact/whole path. It makes it easier too when you have a very long path name to a field....as long as your fieldname is unique, you can simply use that name and resolveNode will "find" it for you. It is similar to JQuery methods to locate an element in a DOM for you.

      But yes....nice, quick write up to the original post over in the forums!

      Author's profile photo Prajesh Desai
      Prajesh Desai
      Blog Post Author

      Correct me if i'm wrong,


      first the syntax is, this.rawValue = xfa.resolveNode("somefieldname").rawValue;

      and trick i shown is gives you shortest possible path, so don't worry, whenever it feels it generate xfa.resolveNode syntax also (e.g. when your subform is untitled, when having array of same name control etc).

      Thanks for your input. 🙂

      Hope this helps.

      Author's profile photo Christopher Solomon
      Christopher Solomon

      Yes....sorry...was typing quickly and error in syntax....but the point is the same...good practice to use resolveNode to make sure it finds your element correctly in the form structure unless you are absolutely sure you are using a unique name and/or you full element path will not change.

      LiveCycle ES2 * Adobe LiveCycle Designer ES2

      Author's profile photo Prajesh Desai
      Prajesh Desai
      Blog Post Author

      Correct me if i'm wrong,

      yes, you can wrap generated code into xfa.resolveNode if you want. but as per my understanding xfa.resolveNode will search and fieldname will point, so i preffer to point instead of serching.

      Author's profile photo Pankaj Kumar
      Pankaj Kumar

      Hi Prajesh,

       

      This post is simply awesome. Thanks a lot for wonderful post. It helped me a lot.

       

      Author's profile photo Prajesh Desai
      Prajesh Desai
      Blog Post Author

      Happy to see helpful to you. ?