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
Edward VazquezEdward Vazquez 

Salesforce Email Templates Question

User-added image

This is some of the html for my email template that shoots out automatically.The applicant names are not always all filled out it just depends on the specific contact record. Some may have 1 applicant, some may have 2, and some may have all 6. My Question is how do I add commas to seperate the applicant names only when needed. I don't just want to have commas with blank spaces. Any ideas?
JustAGirlyGeekJustAGirlyGeek
I would suggest creating a formula field to check for the blanks and format the output accordingly. Then use the formula field in your template in place of all of the other fields.
Edward VazquezEdward Vazquez
Any idea on how to write the formula or at least start it?
JustAGirlyGeekJustAGirlyGeek
Sure, can give it a shot, just need a little more info. Are the applicant fields always filled in number order or would there be a case where Applicant 1 would be blank but Applicant 2 is filled out?
Edward VazquezEdward Vazquez
The fields are always filled in number order. Thank you for your help.
JustAGirlyGeekJustAGirlyGeek
Give this one a go:

IF (
NOT(ISBLANK(Applicant_6_Name__c)),
Applicant_1_Name__c & ", " &
Applicant_2_Name__c & ", " &
Applicant_3_Name__c & ", " &
Applicant_4_Name__c & ", " &
Applicant_5_Name__c & ", " &
Applicant_6_Name__c ,

IF (
NOT(ISBLANK(Applicant_5_Name__c)),
Applicant_1_Name__c & ", " &
Applicant_2_Name__c & ", " &
Applicant_3_Name__c & ", " &
Applicant_4_Name__c & ", " &
Applicant_5_Name__c,

IF (
NOT(ISBLANK(Applicant_4_Name__c)),
Applicant_1_Name__c & ", " &
Applicant_2_Name__c & ", " &
Applicant_3_Name__c & ", " &
Applicant_4_Name__c,

IF (
NOT(ISBLANK(Applicant_3_Name__c)),
Applicant_1_Name__c & ", " &
Applicant_2_Name__c & ", " &
Applicant_3_Name__c,

IF (
NOT(ISBLANK(Applicant_2_Name__c)),
Applicant_1_Name__c & ", " &
Applicant_2_Name__c,
Applicant_1_Name__c
)
))))