Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

get row values from second table of data

Avatar

Level 2

I am working on an invoice form. This comes from a table of data in XML that holds the main details.

On my form is a table bound to this table, showing columns such as "Line Number", "Item", "Description", "Quantity", "Price", "Total" etc.

On each line, I need to add a delivery number.

Here's the challenge: In the XML, the delivery number is in a totally separate table, which has a reference to the line number of the main details.

How can I get this delivery number from the totally separate table?

What I have done so far, is create a repeating subform within my table, and data-binding to the "delivery table".

Then, I used javascript to compare "invoice line" against the "reference line number" of the delivery table it is repeating over.

If it is the same, presence = "visible", else presence = "hidden".

It feels horrid but was all I could think of. It did work, but for row 1 only.

I removed the javascipt and found it is only looping over the delivery table for the first row of my invoice. My expectation was that it would have looped it for every single row.

Does anyone have any ideas how I should be doing this please?

Thanks in advance

3 Replies

Avatar

Level 10

Hi there,

I'm not sure if this is what you're looking for and if it will work, but you can try using this based on the schema below :

This will call the exact same row of the other table by referencing the index from the row/field which the code is executing.

I hope this will help

Avatar

Level 2

Thanks for your answer,

  unfortunately I cannot link directly by row index, since there may not be an entry in Row1 for the value in Row2.

However, I read through this thread this morning [made more sense than when I saw it on Friday]:

Reading Data from a Table using loop

and I finally have something working, a bit like this

var rowCount = Table1._Row1.count;

var i = 0;

//

this.text = "hidden";

this.field = "";

//

for (i = 0; i < rowCount; i++) {

if (xfa.resolveNode("Table1.Row1[" + i + "].Reference_Line").rawValue

    == xfa.resolveNode("Table2.Row1.Line_Number").rawValue) {

  this.field = xfa.resolveNode("Table1.Row1[" + i + "].Delivery_Number").rawValue;

  this.text= "visible";

  break;

}

Thanks very much for your help!

Avatar

Level 2

... and that is exactly how not to post code... Why did it insert blank lines? Grrrr.