Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

resolveNode returns a null value when a variable is used.

Avatar

Level 2

LiveCycle Designer ES2, Latest version

Hi,

The following Javascript, in the click event of a button, returns a null value for the variable oPage. When I manually enter the expected value the script works perfectly.

I have tried various changes to the resolveNode line such as, var oPage =  xfa.resolveNode(qPage); but without success.

Also studied all the Adobe reference material I could find on scripting and resolveNode. Any suggestions?

var qPage = (Cell12.rawValue+"AnchorField");
app.alert(qPage);
var oPage = xfa.resolveNode("$..qPage");
app.alert(oPage);
var nPage = xfa.layout.absPage(oPage);
app.alert(nPage);
xfa.host.currentPage = nPage;

Thanks,

Ron

1 Accepted Solution

Avatar

Correct answer by
Level 10

I have tried your sample and it seems to be working fine ...but I am not 100% sure what you are trying to do .....going back to your original question about passing a variable into resolveNode, resolveNode expects a string so you have to use the following syntax to be able to create the string:

xfa.resolveNode("$.." + qPage)

Note that the variable is outside of the quotes and as such the string $.. is being added to the contents of qPage. This wil only work if qPage is a string as well.

In your small example you defined qPage as an XFA object so that syntax above will not work. If you intend to use it the same way then you woudl use qPage.name so that the name of the field will be returned (it is a string) and it will be added to your expression of $.. to make the $..ProductAnchorField

So the expression woudl be:

xfa.resolveNode("$.." + qPage.name)

Make sense?

Paul

View solution in original post

9 Replies

Avatar

Level 10

I do not think you can use the $ in that context as it is a shortcut for the current node and the xfa.resolveNode requires a string reference to the node. Try eliminating the $ but use the full path to the object and see if helps (i.e. ...resolveNode("form1.qPage")

Paul

Avatar

Level 2

Maybe I need to add some additional details....


The form contains many Detail Pages, which can each have any number of instances.


Each Detail Page instance has a dynamically generated, uniquely named Text Field.


A button on each Detail Page adds an instance of a table row on a Summary Page, and populates the newest instance  of the row with data.

.
On the Summary Page, the value of the variable qPage, based on Cell12, matches the name of a Text Field on a specific Detail Page.

This code needs to be able to locate the absolute page number of any page, based on the value of the variable qPage.


I use this method with a manually entered string value for static pages, and it works great, however when passing in a variable, which should represent a string value, the Javascript returns a null value.


I have tried:
var oPage = xfa.resolveNode("$..qPage");
var oPage = xfa.form.resolveNode("$..qPage");
var oPage = xfa.resolveNode(qPage);
var oPage = xfa.resolveNode(..qPage);
var oPage = xfa.resolveNode("qPage");
var oPage = xfa.resolveNode("..qPage");
var oPage = xfa.resolveNode("form1..qPage");
var oPage = xfa.resolveNode("form1.qPage");
From what I have read in the Adobe Livecycle documentation, var oPage = xfa.resolveNode(qPage); should work, but it doesn't.

Avatar

Level 2

Here is a link to a small sample of what I am trying to acomplish.

http://calmark.net/CCWMini.pdf

Avatar

Level 7

Hi,

If I understand correctly, you want to generate a summary based on the selections on multiple pages.

I would wrap the selection page in a non-page-breaking repeating subform. My summary table would (on the calculation event of each field in the repeating summary row), determine it's index and fetch the information in the coresonding page (i.e. the non-page-breaking repeating subform index).

this rawValue = formName.Page1.NonPageBreakingRepeatingSubform[this.parent.index].field1.rawValue;

If you have problems resolving the node, try formCalc, which seems to be a lot more forgiving in resolving nodes:

$ = formName.Page1.NonPageBreakingRepeatingSubform[this.parent.index].field1

I hope this helps.

Stephen

PS you can make this more complex if you have different page templates, too. Wrap all the different "page" subforms (hidden) in a subform(visible). When a user makes a selection, have the appropriate subform (page) appear and make the appropriate corresponding row in that tableSection visible (all other rows in that tableSection hidden). When they want another page, you add another tableSection instance and another templates subform instance.

Avatar

Correct answer by
Level 10

I have tried your sample and it seems to be working fine ...but I am not 100% sure what you are trying to do .....going back to your original question about passing a variable into resolveNode, resolveNode expects a string so you have to use the following syntax to be able to create the string:

xfa.resolveNode("$.." + qPage)

Note that the variable is outside of the quotes and as such the string $.. is being added to the contents of qPage. This wil only work if qPage is a string as well.

In your small example you defined qPage as an XFA object so that syntax above will not work. If you intend to use it the same way then you woudl use qPage.name so that the name of the field will be returned (it is a string) and it will be added to your expression of $.. to make the $..ProductAnchorField

So the expression woudl be:

xfa.resolveNode("$.." + qPage.name)

Make sense?

Paul

Avatar

Level 10

Hi Ron,

Just to give you another idea, I've updated your sample with the approach I would take (at least for item three).  Basically, I would store the somExpression of the detail page in a hidden part of the summary row table and use that to navigate back.

https://acrobat.com/#d=ZUL-ZzYZZfkItKZXvsI2jA

Hope it helps.

Bruce

Avatar

Level 2

Thanks for the suggestions, I will digest this information next week and let you know

how it went.

Ron

Avatar

Level 2

Thanks Bruce, your example was exactly the answer I was searching for!

I would have responded sooner but this item was bumped down on the priority list for the past month, and I am just getting back to it now.

Avatar

Level 2

The indexes of the subforms can change when instances are deleted, so I needed a method of referencing each subform regardless of it's instance index.

The final solution involved Pauls suggested resolveNode syntax to navigate back and forth, as well as remove instances.

Thanks again!

Ron