Referencing objects

Posted in: LiveCycle- Nov 21, 2010 1 Comment

When referencing objects in LiveCycle Designer ES2, you need to ensure that you are providing a sufficiently complete reference to the objects. If you do – the script will work; whereas if you don’t – the script may fail silently.

A sample form is available here: Assure Dynamics Referencing Objects.

Tip 1: name objects as you go!

First off you should name objects as you develop your form. This applies to pages, subforms and other objects like textFields and numericFields. When objects are named it makes it so much easier to reference them in script.  For example if we take an object (“myTextField”) which is inside a subform (“mySubform”), then referencing this object from outside the subform is straightforward:

this.rawValue = mySubform.myTextField.rawValue;

On the other hand if the subform is not named, it has to be resolved in the script first:

this.rawValue = xfa.resolveNode(“#subform[1].myTextField).rawValue;

Both of the above scripts will work; however the second takes additional resources (xfa.resolveNode) and makes the script logic difficult to follow.

Tip 2: use Control+Click to insert references

LC Designer ES2 has a very handy tool, where you can insert the right amount of the object’s reference that is needed in the script. When you are in the script editor, hover your mouse over the object that you want to reference in your script. When you press and hold the Control key, you will notice that the mouse changes to a ‘V’. Now when you click the object, LC Designer ES2 will insert the correct reference into the script.

This feature is extremely useful and you should get into the habit of using it. Two big benefits:

Your object references will be correct.

You will be quicker scripting events.

A demonstration

The sample provides examples of how different objects are referenced, depending on the relative path in-between the objects.

On each pages there are three ‘lights’ that are controlled by their respective on/off button. In addition each page has a toggle state button, that controls each of the on/off buttons.

The main difference between the four pages is the manner in which objects are wrapped in subforms.

Notice that on page 4, the subforms have the same name, which allows the forms developer to use a loop script.

The form is available here: Assure Dynamics Referencing Objects.

One Response to “Referencing objects”

  1. Srinivas says:



Leave a Reply

You must be logged in to post a comment.