Help with message template conditional expression

Il y a 4 semaines
I am using a HTML email template and am getting a blank line for BillingAddress2 when it doesn't exist. It seems the br is still getting inserted. How can I code up HTML to show an address properly based on whether or not billing address 2 exists or not?


%Order.BillingFirstName% %Order.BillingLastName% <br />
%Order.BillingAddress1% <br />
%if(!(%Order.BillingAddress2% == ""))        
%Order.BillingAddress2% <br />
endif%
%Order.BillingCity%, %Order.BillingStateProvince% %Order.BillingZipPostalCode%<br />
Phone: %Order.BillingPhoneNumber%
Il y a 4 semaines
The code looks right. Are you sure the BillingAddress2 doesn't contain spaces? Because if it contains space then the condition is satisfied and <br/> inside the conditional statement will be included

I am not sure if String.IsNullOrEmpty works here. If it does then it will be better to use it.
Can you try this and see how it goes?
%if (%Order.BillingAddress2% !="" && %Order.BillingAddress2% !=" ")  %Order.BillingAddress2% <br /> endif%
Il y a 4 semaines
Thanks, it would be nice if we could run a Trim() on it. I may do this in code and that could solve the issue. Don't really know the capabilities of this script system.