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
Aron Schor 24Aron Schor 24 

Visual Force Email Template adds space (possible newbie question)

Hi,

I have a Visual Force template using If/Then logic.  If the field is blank, don't show it.  However, it adds a space.  How do I fix?

This code:
{!RelatedTo.Requester_Name__r.Name} Text <apex:repeat value="{!relatedTo.Requester_Name__r}" var="con" > {!IF(ISBLANK(con.Field1__c), NULL, (con.Field1__c) + ',')} {!IF(ISBLANK(con.Primary_Field2__c), NULL, (con.Field2) + ',')} {!IF(ISBLANK(con.Primary_Field3__c), '', (con.Field3) + ',')}</apex:repeat> Text.

Displays:
Name Text Field1, Field2, Field3, Text - This is fine (If 3 fields have a value)
Name Text Field1,   Text.  - This is an issue, due to spacing (If just the first field has a value)

Thanks, Aron!
Aron Schor 24Aron Schor 24
I got help on the Success Community
<apex:repeat value="{!relatedTo.Requester_Name__r}" var="con" > {!SUBSTITUTE(IF(ISBLANK(con.Field1),NULL,con.Field1+', ')+IF(ISBLANK(con.Field2),NULL,con.Field2+', ')+IF(ISBLANK(con.Field3),NULL,con.Field3+',, ')+'.',', .',NULL)}</apex:repeat>