Barcode in dynamic table from nested detail table

Hi All,
I have an issue where I need to display a barcode in a dynamic table on the page. The data is coming from a nested table in the datamapper.

The fields listed in the table should show the first item in the first table follow by the first item in the nested table, then the second item in the nested table. The barcode will be the items from the nested table.

Something like this:

record.detail.recordNmuber
record.detail.data.barcode
record.detail.data.barcode
record.detail.recordNumber
record.detail.data.barcode…
etc

Any assistance greatly appreciated.

Thanks

John

Hi John,

Which version of OL Connect are you using?

Erik

The attached template is created in version 2022.2. I created a dynamic table using the Insert Dynamic Table wizard. The first row repeats over the ‘detail’ table where the send row repeats over ‘detail.data’.

I the example I use expressions for regular data (introduced in 2022.2, although this doesn’t really matter for the example). Next I inserted an inline barcode in the table cell (the selected data field is not important at this stage), assigned the barcode element a class via the Attributes panel (‘barcode’) and made the appropriate settings via the Barcode Properties dialog (right click the barcode object).

Subsequently I changed barcode script so it sets the content of the barcode element to the text of the respective data row. First I changed the selector of the script to ‘.barcode’, expanded the script and deleted the code.

When iterating over items in a detail table your script has access to the detail record used for that row. This information is accessed via the ‘this’ object. For convenience sake I changed the scope of the script to “each matched element” (so the scripts iterates automatically over all .barcode elements). This allows you to work directly on the matched element and the accompany data as shown in the image below.

With this setup there is no need to create ‘for loops’ etc. Rows are repeated by the dynamic table logic and as mentioned they are ‘aware’ of the record/detail record used to render this row.

Hope this helps (and hope it works for you;),

Erik

Hi Erik,

I was just about to reply to your first post but that’s brilliant. I’ll have a look and let you know how I get on. It’s 2022.2

Thanks

FYI. You can load my sample data (in JSON format) using the JSON sample data editor option found in the Data Model pane.

Thank you Erik, That works perfectly. It has raised a secondary issue though. If there are 3 items or less then I need to show the barcode. If there are any more than that I should not show any barcodes. Is there a way to accomplish that?

Sorry, should have thought of that when first posting.

Thanks

Something like this?

No sorry, not quite.

The rows you have numbers in will be shown but not counted towards a total. If there are more than 3 of the other rows, in total, then it will not show any barcodes. If there are 3 or less of the other rows then each will have a barcode. In your example there would not be any barcodes.

Hope that makes sense.

J

Like this?

The quickest I could come up with is loading a snippet with a simplified table (no barcode rows) and replace the base table when there are more than 3 detail rows.

barcode-in-dynamic-table-2.OL-template (9.9 KB)

Hi Erik,

Thanks for coming back so quickly. This is tough to explain.

Not sure if these pictures will show properly.

Total of no more than 3 items:

image

Total of more than 3 items:

image

Hope this helps.

J

Hi Erik,

Thanks for helping with this. I’ve attached a datamapper file to try to explain things better. The first record contains a total of three items in the detail table (in the nested ‘code’ table) and this should show barcode. The second record has four items in the detail table (again in the nested table) and should not show the barcodes. It’s based on the total number of items and not the length of a table.

barcode table.OL-datamapper (4.5 KB)

Thanks,

John

Thanks that was helpful. Attached a new version of the template. I’ve used the same technique as the previous template but changed the logic to determine when to load the snippet. The scripts iterates over the detail data and accumulates the number of nested ‘code’ levels.

Let me know how it goes.

Erik

barcode-in-dynamic-table-3.OL-template (10.0 KB)