avoid empty lines in templates if value is blank

Hi all,

I have a template to create a PDF document, which contains:

<<If: ISNOTBLANK([Textblock 1])>><<[Textblock 1]>><<EndIf>>
<<If: ISNOTBLANK([Textblock 2])>><<[Textblock 2]>><<EndIf>>
<<If: ISNOTBLANK([Textblock 3])>><<[Textblock 3]>><<EndIf>>

If e.g. "[Textblock 1]" is blank an empty line exists, but if "[Textblock 1]" is not blank it should be in a new line.

How can I avoid the empty line?

I tried:

<<If: ISNOTBLANK([Textblock 1])>>
<<[Textblock 1]>><<EndIf>><<If: ISNOTBLANK([Textblock 2])>>
<<[Textblock 2]>><<EndIf>><<If: ISNOTBLANK([Textblock 3])>>
<<[Textblock 3]>><<EndIf>>

But this throws an error: 'If: ISNOTBLANK([Textblock 2])' is invalid due to: Unable to find function 'IF: ISNOTBLANK', did you mean 'ISNOTBLANK'?

I tried:

<<If: ISNOTBLANK([Textblock 1])>><<
[Textblock 1]>><<EndIf>><<If: ISNOTBLANK([Textblock 2])>><<
[Textblock 2]>><<EndIf>><<If: ISNOTBLANK([Textblock 3])>><<
[Textblock 3]>><<EndIf>>

But this throws also an error: Contains start token '<<' without matching end token '>>'

Thanks, Joachim

 

0 7 352
7 REPLIES 7

Keep in mind that the IF's and ENDIF's do not take up lines in the generated doc.

Try it like this:

<<If: ISNOTBLANK([Textblock 1])>>
<<[Textblock 1]>>
<<EndIf>>
<<If: ISNOTBLANK([Textblock 2])>>
<<[Textblock 2]>>
<<EndIf>>

<<If: ISNOTBLANK([Textblock 3])>>
<<[Textblock 3]>>
<EndIf>>

 

Thank you @WillowMobileSys ,

I'm not sure if I understand you, but

<<If: ISNOTBLANK([Textblock 1])>>
<<[Textblock 1]>>
<<EndIf>>

will make an empty line if [Textblock 1] is empty.

Did you try it?

yes, see the empty line between "Sehr geehrte Frau..." and "der รถrtliche..."

ScreenShot 627 getappfileurl - Google Chrome.jpg

In your case you should be using an IFS() instead of a Template IF

IF() | AppSheet Help Center

IFS() | AppSheet Help Center

Template If Expressions | AppSheet Help Center

Template If is used when you want to hide certain portion on your template:

SkrOYC_0-1648499397728.png

So, use this instead:

<<IFS(
ISNOTBLANK([Textblock 1]), [Textblock 1],
ISNOTBLANK([Textblock 2]), [Textblock 2],
ISNOTBLANK([Textblock 3]), [Textblock 3]>>

 

Thank you @SkrOYC I will try this tomorrow

Ahhh.  What you are seeing is NOT a blank line.  It is the default Paragraph spacing. 

I assume you are using Google Sheets?  You will want to use the Custom Spacing option to adjust the space between lines.  See below.

 

Choose "Custom spacing" option

Screen Shot 2022-03-28 at 5.17.11 PM.png

 

Adjust the Paragraph spacing points

Screen Shot 2022-03-28 at 5.14.24 PM.png

Then you will go from This...

Screen Shot 2022-03-28 at 5.22.25 PM.png

To This (only the Blocks side was changed)...

Screen Shot 2022-03-28 at 5.22.13 PM.png

 

Top Labels in this Space