I need to get some data from a nested table to the top level of the record to use it in the table wizard in Designer. From what I understand so far the Table Wizard is not able to work with nested tables.
So I want to access the relevant nested table in Datamapper and write the data to a top level table.
I tried a lot of things today and I’m pulling my hair out.
See attached screenshot.
I manually created a table in the datamodel (see 1. in screenshot) and fields for it that I want to fill with data in an Action step Javascript.
When I try to add rows or records to that table I get the error message
"cannot call method addRow of undefined"
When I access the table in the Javascript editor via point notation I am offered “Lieferscheinpositionen”, but despite the fact I created it in the datamodel as a table it seems to be of type “unique tag” instead of array and “unique tag” does not have the methods addRow() or set().
How do I change the table I created manually into an array? And why is a table that was created by “add Table” in the datamodel not an array?
Thanks. I will again have to create a template/datamapper with sanitized data without real customer data to provide it to you. That will take some time.
But my main question is: If I manually create a table in the data model (and the UI explicitly gives me the option via context menu), why can’t I fill it with data and why is the table not an array?
The problem is:
I have invoice data as xml. The xmls are per order, not per package. If an order creates multiple packages due to shipment needs, I get two invoice xmls and both contain all packages. I have to determine which package positions are relevant for the current xml file. I have a way to determine that by comparing the current invoice file shipping barcode with the multiple packages in the xml and determining which one of the package nodes is the relevant one.
“Below” the Package node are the Packageposition nodes holding the article data for that package.
So I have one loop on package and inside that a second loop on packagepositions (you can see that in the screenshot).
I need to output the article positions for the correct package in the delivery slip I am trying to build. But Table Wizard does not let me create a table from a nested datamodel table. SO my approach was to determine the correct article positions in the Datamapper and just write them to a top level Table I created manually. Just filling that table does not work with the addRow() or other methods, since the Table is no array, but a “Unique Tag” as shown above.
I just need a way how I can turn my manually created table into e real one. If I get that information, my problem should be solved.
The desired end result is an article table from Paketpositions of the correct Package
I cannot select the relevant package that way. If I do it this way and just add switch through the packages in the datamodel in Designer, the table in the preview stays the same: The Paketpositions from the first Package. I need to select the correct package packagepositions and this seems not to be possible this way.
This is because I cannot select the correct package in the Table Wizard:
This is not a Designer problem, this is a Datamapper problem.
So my question still is: How can I fill a table I created manually in the Datamodel with data? It looks a little to me as if you are trying to avoid that answer.
Just trying to help here and provide you with info on a component that I know best. Based on the first line in your initial message I had the impression you already had a data model with nested details. This gave me the impression you abandoned that track as you believed the Table Wizard is not able to work with nested tables.
I have a datamodel with nested details. That is exactly what does not work in Designer as decribed above. If you need more information to understand the problem, please provide me with the details you need beyond my detailed explanation in
Your observation is indeed correct, for some reason manually created detail tables are not recognized as array. This explains why the addRow() method does not work. I’ve create a bug report for that (internal ref SHARED-91030).
Having a better understanding of the desired design would be helpful looking at workaround.
You mentioned “This is because I cannot select the correct package in the Table Wizard:”. What do you mean with that? Do you need to fetch a specific record from that detail data?
I can have multipe packages nodes in an xml file, so I have a packages table with multiple entries.
“Below” the package node are multipe paketposition nodes. Paketposition is a nested table of Paket.
One of those package nodes is relevant for the current xml invoice, not all of them. I determined the relevant package in the Datamapper, so I know the index of the relevant package.
In the Table Wizard I can only select paket.paketposition. So I always only get the paketposition fields for one package of the data table. I do not need to iterate over packages in the Table Wizard, showing all packages and all subsequent Paketpositions of those Packages. I only need the Paketpositionen for the one Package relevant to this invoice.
But I would need to select paket[relevantPackage].paketposition.
One way to achieve things is to add an extraction step and copy the respective Paket data to a JSON data field. This you can easily add the properties of these fields to your template. Assuming you are on 2023.1 and using Expressions.
I found using json extremely confusing since the info about using it in the documentation is nearly nonexistent and the blog entry on the topic mainly was about single fields.
JSON.stringify(record.Paket[record.NrRelevantesPaket-1].Paketposition.fields);
and to test it with a hardcoded index: JSON.stringify(record.Paket[0].Paketposition.fields);
I get “undefined script result” in the Extraction step.
And when I see it, this cannot work, since I do not have just one Paketposition, but multiple. That I need to give out in a table, one row for each Paketposition fieldlist.
That certainly is an option but will kill a lot of work I have already done so I am very reluctant to do this. The best solution would still be to be able to create a new table that I can fill with the relevant data. Or maybe a json loop of some kind. I already literally wasted days of time because of the “manually created table that cannot be filled with data” bug.
After a week of extreme frustration with Datamapper I will now have to do some other work that was left behind because of this and is now urgent. I will let this sink in and come back to it next week.
I tried multiple things here, but even the correct condition is a problem. This is a very convoluted “workaround” for the table bug and so far I have not gotten it to work as expected.
Can I just type this equation or does the Javascript need to return a true or false value? There is nothing detailed about using Javascripts in Conditions in the documentation.
If I then do a Repeat on
./Paketpositionen/Paketposition
Add an Extract and add the relevant fields to the Extract step all fields are empty in the Datamodel, even if I switch through the Pakete
To ascertain if the current package is the correct one, still all Paketpositionen are extracted, instead of only the ones from the relevant Paket.
In addition, if I select all relevant fields and choose “add to extraction” (as shown in the documentation), I manually have to correct all field xpaths. Is this the expected way it should work?
Here is the recent try. Please note that this is a state after hours of experimenting and may not be in a usable state regarding the second Pakete-Repeat.
I added an additional Repeat for Pakete, so I did not get lots of errors in the Action steps because I removed or altered the first Pakete-Repeat.