1

I'm trying to get information to conditionally render based on if the field is populated or not. All my fields except for Media_Kit_Comment__c are boolean. Media_Kit_Comment__c is a string and I'm having a hard time getting it to work.

When I try to save the email template I get the error: Error: Incorrect parameter type for function 'not()'. Expected Boolean, received Text

<messaging:emailTemplate subject="You have a new lead: {!relatedto.FirstName} {!relatedto.LastName}, {!relatedto.Company}" recipientType="User" relatedToType="Lead">
<messaging:htmlEmailBody > 
    <html>
        <body>

            Hey {!$User.FirstName},<br/><br/>
            You've been assigned a new lead from {!relatedto.Site__c}. Here are the details: <br/><br/>
           <b>Name:</b> {!relatedto.FirstName} {!relatedto.LastName} <br/>
           <b>Company:</b> {!relatedto.Company} <br/>
           <b>Title:</b> {!relatedto.Title} <br/>
           <b>Email:</b> <a href="mailto:{!relatedto.Email}">{!relatedto.Email}</a> <br/>

           <!--The next bunch of code just renders the label and field conditionally. -->
           <b><apex:outputText value="{!IF(NOT(!relatedto.Agency__c),"Agency:",NULL)}" /></b> <apex:outputText value="{!IF(NOT(!relatedto.Agency__c),"Yes",NULL)}"/> <br/> 
           <b><apex:outputText value="{!IF(NOT(!relatedto.Food_bev_manufacturers__c),"Food & bev manufacturers:",NULL)}" /></b> <apex:outputText value="{!IF(NOT(!relatedto.Food_bev_manufacturers__c),"Yes",NULL)}"/> <br/> 
           <b><apex:outputText value="{!IF(NOT(!relatedto.Grocery_retailers__c),"Grocery retailers:",NULL)}" /></b> <apex:outputText value="{!IF(NOT(!relatedto.Grocery_retailers__c),"Yes",NULL)}"/> <br/> 
           <b><apex:outputText value="{!IF(NOT(!relatedto.Restaurants__c),"Restaurant:",NULL)}" /></b> <apex:outputText value="{!IF(NOT(!relatedto.Restaurants__c),"Yes",NULL)}"/> <br/> 
           <b><apex:outputText value="{!IF(NOT(!relatedto.Higher_ed_admins__c),"Higher Ed Admins:",NULL)}" /></b> <apex:outputText value="{!IF(NOT(!relatedto.Higher_ed_admins__c),"Yes",NULL)}"/> <br/> 
           <b><apex:outputText value="{!IF(NOT(!relatedto.K12_admins__c),"K-12 Admins:",NULL)}" /></b> <apex:outputText value="{!IF(NOT(!relatedto.K12_admins__c),"Yes",NULL)}"/> <br/><br/>
          <apex:outputText value="{!relatedto.Media_Kit_Comment__c}" rendered="{!ISBLANK(!relatedto.Media_Kit_Comment__c)}"/>

           Click link to go to the record in Salesforce:  <apex:outputlink value="{!LEFT($Api.Partner_Server_URL_140,FIND('.com',$Api.Partner_Server_URL_140)+4)+relatedTo.Id}">https://na39.salesforce.com/{!relatedto.Id}</apex:outputlink> <br/><br/><br/>

           <i>P.S. If this lead was assigned to you by mistake, please let your Sales Ops team know!</i><br/>



        </body>
    </html>
</messaging:htmlEmailBody> 

Below is an example of how the email works. See how Agency is visible because the Agency checkbox was checked on the record. I'd like the Media Kit Comment to render conditionally as well, but the fact that it is a string is throwing me.

enter image description here

The specific line that is giving me grief is:

  <apex:outputText value="{!relatedto.Media_Kit_Comment__c}" rendered="{!ISBLANK(!relatedto.Media_Kit_Comment__c)}"/>

Thanks!

0
2

You are using bind expression(!) again and again. Bind expression should be used only once. Using it again makes it a NOT(!)

Thus this

<apex:outputText value="{!relatedto.Media_Kit_Comment__c}" rendered="{!ISBLANK(!relatedto.Media_Kit_Comment__c)}"/>

is trying to use NOT(!) operator on text field Media_Kit_Comment__c which not possible.

Solution: Use Bind expression only once.

<apex:outputText value="{!relatedto.Media_Kit_Comment__c}" 
rendered="{!!ISBLANK(relatedto.Media_Kit_Comment__c)}"/>

Also I would like to add, You have done same for other fields as well, which would provide you wrong results.

4
  • Thanks Pranay. For rendered = !ISBLANK that is supposed to render the text in the field if it's not blank, correct? I'm testing it now with a record where that field isn't blank and nothing is rendering at all.
    – Cynthia
    Oct 15 '18 at 20:19
  • @Cynthia updated code: added an extra not. (!!ISBLANK) Oct 15 '18 at 20:20
  • Thanks! But also, your last comment about how I've done the same for other fields--I'm not getting incorrect results with that. When my boxes are checked they rendering correctly.
    – Cynthia
    Oct 15 '18 at 20:22
  • I modified the code to <apex:outputText value="{!!ISBLANK(relatedto.Media_Kit_Comment__c)}" rendered="Any notes about their marketing:"/><br/> and nothing is rendering. But I purposely am asking it to state the "Any notes..." text if the field is not blank. Any ideas?
    – Cynthia
    Oct 15 '18 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.