Dynamic Layout Adjustment: Hiding Empty Fields in PDF Reports

Pessoal, preciso ajustar a lógica do relatório no AppSheet porque está acontecendo o seguinte:

Hoje temos 20 campos de imagem e 20 campos de observação no formulário. Porém, na prática, às vezes usamos só 5 fotos com 5 descrições.

O problema é que, na hora de gerar o PDF, o AppSheet imprime todos os blocos do template (Imagem 1 até Imagem 20), mesmo que vários estejam vazios. Com isso:

Ficam espaços em branco no relatório

A assinatura, que deveria ficar logo após a última foto usada, vai parar lá no final do documento

O relatório fica visualmente desorganizado

Eu tentei resolver isso usando ISNOTBLANK nas colunas (Show_If no App), mas isso só controla a exibição no formulário. O PDF não respeita o Show_If — ele imprime o que estiver no template do Google Docs.

Então o controle correto precisa ser feito no template do relatório, não no formulário.

O que deve ser feito:

Cada bloco de imagem + observação precisa ser envolvido com uma condição no template, assim:

<<IF: ISNOTBLANK([Imagem X])>>
Imagem X
<<[Imagem X]>>

Observação X
<<[Observacao X]>>
<>

Dessa forma:

Se a imagem não estiver preenchida, o bloco inteiro não aparece no PDF

Não fica espaço vazio

A assinatura sobe automaticamente para logo após a última imagem utilizada

O relatório fica limpo e organizado

Resumindo:
O erro não está nas colunas do App, está no template do Google Docs que precisa ter IF/END em cada bloco.

Depois que isso for feito em todas as imagens, o PDF vai imprimir somente o que realmente foi preenchido.

1 Like

You can use IF statements in your templates to control flow. Refer to this article for more details.

I hope this helps!

2 Likes

Hi @Lofts_AppSheet

I’m a beginner here but I try to help you with my perception. You should complete it first in appsheet before converting it to pdf. so you need to create a virtual column with the criteria you want. example Virtual column RESULT_IMAGE_A (as image type) with formula :

IF([ID_Template]=“TPL000”,TEXT([Hasil_image0]),IF([ID_Template]=“TPL001”,TEXT([Hasil_image1]),IF([ID_Template]=“TPL002”,TEXT([Hasil_image2]),IF([ID_Template]=“TPL003”,TEXT([Hasil_image3]),IF([ID_Template]=“TPL004”,TEXT([Hasil_image4]),[Hasil_image5]))))) .

So you just write in google doc <<[IRESULT_MAGE_A]>> . You don’t need to write the IF statement again in the bot template (Google Doc), as it’s already been completed in the virtual image column A for the image you want. I hope my perception is correct, as I’ve never tried it in a bot.

One reason the template issue you are facing is because template expressions will not take care of a Google doc table cell elements in the template, if the expressions are physically entered in each table cell for the same table record.

A better possible arrangement will be to include a different images table and make it a child table of the main table where you have other data. Please make this Images child table a “IsPartOf” main table. The user can then easily add as many images as required in the child table for a single main table record.

Handling data in the child table with << START >> expressions is much easier in templates. The table cells will show in the PDF report for just as many images in the child table for a main table record. Please refer the help article about the << START >> expressions in the template.

An example below. In an order capture app, the order details table has three line items in the child table of the order, so only 3 rows are shown in the PDF.

On the other hand, the following order has 6 line items , so 6 rows are displayed in the PDF report.

The relevant start expression in the template is as follows. Once the start expression is placed in the template table as shown below, it will create only as many rows of images as in the related child records.

So your template can be something like

Main Table Column 1 : <<[Main_Table_Column_1]>>

Main Table Column 2 : <<[Main_Table_Column_2]>>

Main Table Column n : <<[Main_Table_Column_n]>>

The Images table will have the following columns in general

4 Likes