Expand my Community achievements bar.

SOLVED

Problem binding to directly to data connection

Avatar

Level 7

I have a data connection in my form and I need to loop through the data within the node items. On the form ready event I have:

var a = xfa.resolveNode("$record.message.node[*]...").value

The loop should replace the * with a number starting at 0 and run till done. It does not work. I have tried to modify this with resolveNodes and other attempts.

I was able to cheat a bit and create a dynamic table and load the data into the table first, then use the loop to go through the data within the fields. It works but this is an extra step, that I should be able to avoid.

Any help would be greatly appreciated.

the script I would like to use is below. Something is not working in setting the variable directly to the data node.

var vDescItems = xfa.resolveNode("$record.message.controlActProcess.reasonOf[*].detectedIssueEvent.value.code").value

for(i=0; i<vDescItems.length; i++)

{

    if (vDescItems.item(i).rawValue == "C53566")

    {

     do something

     }

}

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi there,

to accomplish the the code you have provided, first you should be using the resolveNodes() method instead of resolveNode()

Also if this is still not working try accessing the value property only in the loop instead of accessing it right after calling resolveNodes()

Hope this help!

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

Hi there,

to accomplish the the code you have provided, first you should be using the resolveNodes() method instead of resolveNode()

Also if this is still not working try accessing the value property only in the loop instead of accessing it right after calling resolveNodes()

Hope this help!

Avatar

Level 7

Thank you for the reply. I did attempt to use xfa.resolveNodes. That still returned no value. I ran a test by setting similar to below:

var vDescItems = xfa.resolveNode("$record.message.controlActProcess.reasonOf[1].detectedIssueEvent.code.code").value

TextField1.rawValue = vDescItems

the test yielded the correct node data. However when I used a loop to provide data in that node, I received no returned value. the only way I was able to accomplish this was to populate a table with the data and then loop through the table to get the results. It works but it is not as clean as I would like to see.

Also I did try to use the .value property in the loop and that did not work either.

Avatar

Level 10

When using resolveNodes method, you specify value and as I can see in your loop you specify rawValue... you should access the value only once.. either in your resolveNodes statement or within the loop

Avatar

Level 7

You were completely correct. My code was a bit messed up. I properly placed the .value and cleaned up the code. It is working correctly now. Thanks very much for all the help!!!!