Expand my Community achievements bar.

help referencing a field

Avatar

Level 3

I have a form with a number of pages of fields, and then a final page with a "Miscellaneous_1" field that can expand to multiple pages.  In order to get that field to expand, a coworker (who built this form before me) had to wrap it in a subform and set some properties and such.  Here are some details about this particular field:

It's a Text Field (obviously?).  It is in the hierarchy as shown below.

Capture.JPG

I don't know if these facts are relevant to the problem I describe below, but there are some strange settings for the pagnation of the subforms that Miscellaneous_1 sits in, in order to achieve the page overflow onto additional page(s).  I can't imagine that those details are relevant, but if they are let me know and I'll spend some time trying to figure out what those details are.

Other than that, this is just like any other field in my form (as far as I can tell).  But, I can't reference this particular field (for some reason) when I'm writing event scripts for other objects.

If I do a shift-ctrl-click on the Miscellaneous_1 field while in my event script for another form object, I get the following absolute path:

xfa.resolveNode("form1.#subform[18].MiscParentSub.Miscellaneous_1")

I've tried a number of ways to reference the field (with the appropriate .rawValue or .isNull extentions, depending on what I'm trying to do).

xfa.resolveNode("form1.#subform[18].MiscParentSub.Miscellaneous_1")

Miscellaneous_1

xfa.resolveNode(Miscellaneous_1.somExpression)

xfa.resolveNode(xfa.resolveNode("form1.#subform[18].MiscParentSub.Miscellaneous_1").somExpression)

I've even tried defining a variable as each of those somExpressions and then trying to reference that variable.  Nothing has worked.

Any insights or guesses on what I need to do to reference this field in my event scripts are appreciated.

Thanks!

Emily

3 Replies

Avatar

Level 10

Hi Emily,

I would recommend that you name all subforms (including the page containers). If you have a lot of scripting then you would need to go through and update the script for the new references.

We use a capital P for master pages (Page1) and a small p for actual pages (page1). This way when you reference objects you will not have to use xfa.resolveNode at all. Instead the fully qualified reference would look like with the .rawValue added on:

form1.page19.MiscParentSub.Miscellaneous_1.rawValue

Referencing objects should not be affected by pagination settings.

Hope that helps,

Niall

ps maybe try it first on (untitled Subform)(page 19) first.

Avatar

Level 3

I (somewhat) solved my problem.  I thought maybe the field's xml code had gotten corrupted somehow.  So I deleted the field, and inserted a new one with same name and properties.  This one works fine.  Go figure.  I looked at the xml before I deleted the field, and I couldn't see anything obviously wrong with it, but then again I'm no xml expert.  Very strange.

Naill, I will definitely be naming my subforms/pages from now on.  I'm trying to avoid that on this particular form, because by the time I inherited this project there were reams of code already existing.  I'd have to take days or weeks just to update all that.  But your suggestion is now part of my standard operating procedure for any new forms I make.

Thanks,

Emily

Avatar

Level 10

Glad you got it working Emily,

I fully understand the pain of renaming objects. If you had access to LC Designer ES2, then John Brinkman has a sample of a macro for refactoring, which could help you out. You can find it here.

Having said that, if at this stage it is not broken, then don't fix it!!

Good luck,

Niall