Getting an error when using <<If>><<EndIf>> in a template for an email attachment

Hi all,

I'm trying to make use of an IF expression in an email attachment (xlsx) template but I'm encountering an error.
The template works fine without the IF expression included, and the only reason I'm attempting to add it is to improve the presentation by showing the same data with some conditional formatting.

The IF expression is inside a <<Start>><<End>> (Thus the <<End>> appended to the expression)

<<If: ([Condition] = "New")>><<[Condition]>><<EndIf>>
<<If: ([Condition] = "Used")>><<[Condition]>><<EndIf>><<End>>

But instead I get the following error

Screenshot 2023-10-30 at 11.23.46.png

I've directly copied the structure as detailed on the Use If expressions in templates page so I'm unsure what is causing the error.

If anyone has any insights that would be appreciated

0 4 275
4 REPLIES 4

The syntax of the IF's looks fine.  So there must some syntax error PRIOR to the IF's that is causing an issue.  Please show the START template coding before the IF's

Also, I believe the <<END>> for the START must be on its own line.

Thanks for the input @WillowMobileSys. I had a play about with the positioning of the <<End>> expression but that didn't seem to impact it.

However I think I've found the cause...though not the solution. As I mentioned I'm using the IF expression to include formatting. I stripped out the formatting and the the template runs fine, when I put the formatting back in, then it breaks. So something relating to the formatting "appears" to be the issue at least.

I've included the full <<Start>><<End>> below for reference. The actual thing is on a row, but I've included here vertically for easy readability. 

The only formatting applied is to highlight bold, if the value of [Condition] = "New"

<<Start:Filter(โ€œLine Items Shipmentโ€,Month([Stock Change].[Timestamp]) = Month(Today())-1)>><<[Stock Change].[Reference]>>
<<[Timestamp]>>
<<[Warehouse].[Warehouse]>>
<<[Stock Change].[Destination Name]>>
<<[Product Name]>>
<<[Quantity]>>
<<If: ([Condition] = "New")>><<[Condition]>><<EndIf>>
<<If: ([Condition] = "Used")>><<[Condition]>><<EndIf>>
<<End>>


@clilley wrote:

when I put the formatting back in, then it breaks.


What formatting specifically?

 

if I have the expression set to 
<<If: ([Condition] = "New")>><<[Condition]>><<EndIf>>
<<If: ([Condition] = "Used")>><<[Condition]>><<EndIf>>
it runs fine

If I have it set to
<<If: ([Condition] = "New")>><<[Condition]>><<EndIf>>
<<If: ([Condition] = "Used")>><<[Condition]>><<EndIf>>

with the <<[Condition>> set as BOLD, then it breaks

Top Labels in this Space