Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Asiigning variables in scriptobject

Avatar

Level 3

Hi,

Can someone pls help me.

I would like to define all the variables in Script object and assign the field values to each variable.

Now how can i call those assigned variables on the form.

Thank you

Jay

3 Replies

Avatar

Level 10

Hi Jay,

Variables that are declared in script and only available within that script.

Alternatively you can declare global variables or variables that are attached to the <desc> element of an object (http://assure.ly/x1QObn).

Hope that helps,

Niall

Avatar

Level 10

Hi,

one more method that might be interesting for you, if you want to save field values that can be recovered later, is to store the values in the extras element of the fields.

In opposite to the form variables or script objects, which are red-only, you're allowed to create, change and save the extras element at runtime.

http://blogs.adobe.com/formfeed/2011/04/sample-convert-to-strict-scoping.html

Avatar

Level 3

Hi Niall and radzmar,

Thank you so much.

both the informations are very helpful and I got a chance to learn new things.

I was trying with the below script to create the global variable

if(page2.variables.nodes.namedItem("vMyvar") == null)

{

     var vNewVariable = xfa.form-createNode("string", "vMyvar");

      vNewVariable = Page1.TextField1.rawValue;

     Page2.variables.nodes.append(vNewvariable)  

}

1) I'm not sure where I have to write this script on hierarchy of the form, event.

2) How to call this variable on other pages.

Thank you so much for your help.

Regards,

Jay