function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nate Lindo 2Nate Lindo 2 

In an email template, only show section header of specififc fields are not blank

I have an email template that i am trying to customize a bit more. There is a section header called "NRT: Lozenges" with 2 fields under it , 4 mg lozenges and 2 mg lozenges. I want to have "NRT: Lozenges" to only appear if those 2 fields are not null. If those fields are null, i dont want that header to appear.
This is what i have:
<h2>{!IF(NOT(ISBLANK(AND(HCKits__c.X4_mg_lozenges__c,HCKits__c.X2_mg_lozenges__c))), "NRT: Lozenges", NULL)}</h2>

I am trying to have it say if HCKits__c.X4_mg_lozenges__c and HCKits__c.X2_mg_lozenges__c are not blank, populate "nrt: lozenges" and if they are blank, dont populate anything.

Nothing appears when i do this, even if i change "null" to X, X does not appear, even when i have a value for HCKits__c.X4_mg_lozenges__c or  HCKits__c.X2_mg_lozenges__c
SalesFORCE_enFORCErSalesFORCE_enFORCEr
What is the type of your email template? Can you consider creating a visualforce type email template and the use the same conditions?
Nate Lindo 2Nate Lindo 2
It is a custom email template. This one works as expected: {!IF(NOT(ISBLANK(HCKits__c.X4_mg_lozenges__c)), "4 mg lozenges", NULL)} : {!IF(NOT(ISBLANK(HCKits__c.X4_mg_lozenges__c)), HCKits__c.X4_mg_lozenges__c, NULL)} If HCKits__c.X4_mg_lozenges__c is null, nothing appears, if it is not null, it populates the value of HCKits__c.X4_mg_lozenges__c
Nate Lindo 2Nate Lindo 2
I was able to get this working by using:
<h2>{!IF(HCKits__c.X4_mg_lozenges__c >=1 || HCKits__c.X2_mg_lozenges__c >=1,  "NRT: Lozenges", NULL)}</h2>
Nate Lindo 2Nate Lindo 2
ended up using this, which worked: <h2>{!IF(HCKits__c.X4_mg_lozenges__c >=1 || HCKits__c.X2_mg_lozenges__c >=1,  "NRT: Lozenges", NULL)}</h2>