2

I have this Email Template in Salesforce that is capturing information from the lead based on IF Statement conditions.

I understand that in order to use formulas on Email Templates I have to use the regular formula inside curly brackets "{!}".

I have 2 fields for this matter: Field 1: It's a checkbox field - API = Quote_Request_Upholstery_Cleaning__c

Field 2: It's a regular number field (with 1 Decimal point) - API = Quote_No_Bedrooms_HC__c

The condition is as follow: If Field 1 is checked, show Field 2 value. If NOT checked, show nothing.

{!IF(Lead.Quote_Request_Upholstery_Cleaning__c = TRUE, Lead.Quote_No_Bedrooms_HC__c,'')}

Very straight forward, right? At least that's what I thought. This formula seems to work fine with regular text fields but not with number fields. It will not show the values at all. When I use the regular merge field {!Lead.Quote_Request_Upholstery_Cleaning__c} it shows the value without any problems.

Anyone to tell me what seems to be wrong here? enter image description here I'm attaching an image showing the formula. It's a fairly large template with many IF Statements with the same issue. It will work with regular text fields but not with number fields. I feel like if I solve this issue, I'll solve them all. Any help with this issue will be greatly appreciated. Thank you so much.

4
  • 2
    (1) the = true is unnecessary; (2) did you try wrapping the decimal fieldname with the TEXT(..) function?
    – cropredy
    Mar 4, 2016 at 22:59
  • 1
    +1 to @crop1645 feature. I think that because of returned types are different, it 'tries' to cast it to text, but do it bad way in case of number. But i can not confirm that according to documentation. About a lot of ifs -- I would recommend you to make single if <apex:outputPanel rendered="{!Lead.Quote...__c}" layout="none"> panel, put all the content inside, that should be rendered. Save a lot of formula fixes )
    – kurunve
    Mar 4, 2016 at 23:09
  • @kurunve -- outputPanel assumes email template is VF - but it isn't as relatedTo isn't used; but your suggestion is good
    – cropredy
    Mar 4, 2016 at 23:12
  • @crop1645 my bad, but similar approach <div style="display:{!Lead.Quote_Request_Upholstery_Cleaning__c,'block','none' "> ... </div> as alternate solution may do the trick as well. (or span instead of a div, or another property like visibility etc)
    – kurunve
    Mar 4, 2016 at 23:15

1 Answer 1

1

It turned not being a syntax issue. Prior to posting this question, I should have thought about building a test formula field, which I ended up doing so.

The correct syntax would be:

{!IF(Lead.Quote_Request_Upholstery_Cleaning__c = TRUE, Lead.Quote_No_Bedrooms_HC__c, NULL)}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .