Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

xfa.resolveNode does not find fields in tables

Avatar

Former Community Member
I'm using the following code to reference a text field called "my_text_field":



xfa.resolveNode("my_text_field").rawValue = "Hello";



It works fine until I use it with a text field nested in a table. If the field is in a table, the command does not find it. I've tried moving the exact same field in and out of a table and get consistent results.



I'm using LiveCycle Designer 7.1 and saving the PDF as 7.0.5 Dynamic.



Am I using the command wrong? Is there a bug? Is there an alternative command to resolveNode that will allow me to reference fields in tables without having to list all of the parent objects (e.g. not "form1.page1.Table1.Row1.my_text_field.rawValue")?



Thanks,

Charles
4 Replies

Avatar

Former Community Member
Adding to my previous post, I just realized that I don't need to be using "resolveNode" in my code. The following is sufficient:



my_text_field.rawValue = "Hello";



However, my question about an easy way to reference text fields in a table remains. If the text field is in a table, do I always have to say:



[tablename].[rowname].my_text_field



That long reference get cumbersome because I have several different tables, especially because I am moving rows around at this point in development.

Avatar

Former Community Member
So the way resolve node works, if you do resolveNode("my_text_field") it will find it if my_text_field is a child of the same parent or a child of parent of the parent, or.. etc



If you really want to start from the top of the hierarchy and look through everything to just find the node by name you can do something like this.. (this is totally off the top of my head so hopefully the syntax is right).. if the top level form node is named form1:



xfa.resolveNode("form1..my_text_field");



All of this is a horribly bad idea performance wise. When you use resolveNode you are search a DOM node by node looking for a node. It takes time, and as your form grows your performance will plummit. You're much better off taking the time while designing the form and referencing nodes directly. Or when it's impossible to do it directly use resolveNode in a context where you know the node will be found relatively quickly.



Hope that helps.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Thanks, Chris. I was able to create a reference that serves my purpose.



var thisTableTxt = "form1.FormPageD1.Table1";

resolveNode(thisTableTxt + "..my_text_field").rawValue = "Hello";



With this language I can change the order of the rows within one table without needing to update all of the code. At this level, it doesn't appear to affect performance, but I will keep that in mind.



Charles

Avatar

Former Community Member
OK....I think I have a similar issue, but rather than setting a field value I want to retrieve the value of a field.



I have a 10 line table (called "AmountTable") and each line has a field called "Account_No". How do I write the code to loop through each line and retrieve the value of Row[i].Account_No so I can run a RegExp task against it? I've tried Row.Account_No.rawValue, but this only works on the first line...the minute I put [1] into the string it stops working.



Thanks for your help!

Paul