HTML Template : Expression IF/ENDIF not working

Hi everyone,

I’m new to appsheet so I apologize if I’m making any mistake on how this forum works.

I’m generating a PDF document through a bot with an HTML template and it’s working perfectly.
Unfortunatly when I use the IF / ENDIF statement (in order to show/hide some pages) I have the following error messages in the monitor log :

Unable to find function ‘IF:’, did you mean ‘IF’? […]
Expression ‘Endif’ is invalid due to: Expression refers to undefined field

It is written like this in my HTML document :

  <<If:(COUNT([Related MyTable])>2)>>
 	Page to display

It seems that it doesn’t recognize the IF: function in the HTML template document.
I use to have a word document template working with this expression so I’m quit sure it is correct.

I’ve been looking a lot through this great forum but didn’t find any answer.
Hope anyone can help me.

Thank you and have a great day.

Don’t escape << and >>:

<<If:(COUNT([Related MyTable])>2)>>
 	Page to display
1 Like

Hi Steve,

Thank you for the reply.
The problem is that when I put it like that I’m getting this error message :

Name cannot begin with the ‘<’ character, hexadecimal value 0x3C. Line 1235, position 2. Error: The document body is empty.

Beside, in the entire HTML template I’m using everytime the

&lt;&lt; and &gt;&gt; 

to replace the

 << and >>

and it’s working great

Hi everyone,

Anyone who can help me on this ?

Just to let you know that on my HTML template I’m using this kind of conditions :

&lt;&lt;lookup(Useremail(),Users, Email,Prénom)&gt;&gt;

or this

&lt;&lt;If(ISNOTBLANK(INDEX([Related Photos][Libellé],1)),INDEX([Related Photos][Libellé],1),"")&gt;&gt;

And it works perfectly.

I really don’t understand why it doesn’t allow me to do the “IF:” “ENDIF” which is I think the only way to hide pages unless you have any other ideas.

I’m stuck and would be really grateful if you could lend a hand on this …

I finally found it and it was so simple that I feel a little embarrassed right now :roll_eyes:

I was only missing to put the formula inside a paragraph

<p> </p>

Thanks anyway.


Thanks for sharing @Sebastien_Hourcaillo

I am making mine in google docs. I have spent several hours the past few weeks trying to figure out why my templates would sometimes throw this error when I made small changes to nested IF-statements.

Your discovery gave me a lead to chase. I experimented with soft and hard returns, and… it appears that using hard returns between the start tags of two IF-statements break the connection between the opening <<IF: ... >> tag and the closing <<Endif>> tag.

Example of what I mean:

<<IF: [column_level1]>> //** Hard return *//
    <<IF: [column_level2>>

Given that a GDoc is still just a webpage, this would wrap the start and the end tag in different paragraph tags.

Take away: whether you build your templates in HTML or Google Docs, make sure to put your IF-statements in a single paragraph.

Note to the Appsheets team:
I did not discover this earlier because Google Docs has a number of limitations, including that you can’t visualize things like soft and hard returns, section and page breaks.

A small section in the documentation about these common, but hard to detect errors would be very helpful to avoid lots of frustration.