I am encountering an issue with dynamically hiding rows in a document generated from a JSON data source using Plumsail Documents. My use case is an invoice, where some invoice entire have a list of items, some not. At the moment, if no items are available, my document has empty rows.
My goal is to generate a document where certain rows are included or excluded based on the presence and contents of an 'items' attribute within each object of my JSON array. For this reason I check if the entry type is 931290003, but I am open for other options.
I tried several syntax possibilities, but I did not manage to achieve the desired results.
The hide-block-if formatter works with single blocks of the document. To hide items from an array, we recommend to use the filter operation instead of hide-block formatter.
Please check out the example of hiding table rows and try to adjust your template the same way using the filter operation.
I tried several combinations and around 50 times did tests.
I think the 2. Printscreen is the closest that it gets. But I still get the empty lines, same as with hide block option. Do you have any suggestions how to change the template, @Petr .
Variant 1: Filter direct in the lines
This is what I achieved with my testing and the provided JSON:
There are 3 entries (tkp_dateofservice) in the JSON:
17.01.2024
27.03.2024
27.06.2024
Only the second entry has the items array. First and third ones don't.
I tried wtih the filter option but decided to use hide-block-if-nothing formatter and place the items into the same cell as the entries but as a bullet list.
I am having trouble adding the "format" function, as in the parent items. Is that not supported?
{{entries.items.Item_Price}:hide-block-if-nothing}{{entries.items.Item_Price}:format(C, de-CH)}