Hide rows from child items

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.

Here you can find the documents
Documents

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.

{{entries.tkp_entrytype}:hide-block-if(value != 931290003)}
{{entries}:hide-block-if(value.items tkp_entrytype!= 931290003)}
{{entries.items.tkp_entrytype}:hide-block-if(value != 931290003)}

I am using this template in Power Automate to generate a Word, than convert it to PDF.

Hi @nataliWinOn365,

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.

Hide table rows

Best regards,
Petr
Plumsail team

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


Variant 2: Filter with entries items -> adds extra lines

Variant 3: Filter with entries - items are missing

Variant 4: Filter with entries - mixed order

I truly appreciate every idea, as I am running out of time and options.

Hi @nataliWinOn365,

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 didn't change your JSON and this is the result I get with my template and your JSON:

In that case, we have all 3 entries and the second entry has the items names and pricing.

I uploaded the corrected template to your OneDrive folder. Please give it a try with your JSON.

Best regards,
Petr
Plumsail team

That worked wonderfully.


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)}

Hi @nataliWinOn365,

I added the format option and it worked for me:

{{entries.items.Item_Price}:hide-block-if-nothing}{{entries.items.Item_Price}:format(C, de-CH)}

Try to resave the template and test it again.

This is my result:

Best regards,
Petr
Plumsail team

Thanks a lot for your support. It worked.

1 Like