Visualforce email template table row conditional with no controller

apexemail-templatevisualforce

I'm not very salesforce savvy and I need some assistance.

I need to separate the table below in two displays on the email

one for when the Type__c is Online and other when the Type__c is Inperson

I am having trouble making it work, then I tried like the code below it show me an Boolean expected error

for example is display it like this now and I want to separate by type and show two tables on for online and on for in person(where i have multiple results)
![enter image description here

<apex:repeat var="rx" value="{!relatedTo.SDI_Rep_Trainings_Relationship__r}">
   <tr>
      <td>
         <apex:outputText value="{!IF(!rx.Type__c == 'Online', !rx.Type__c, '')}" />
      </td>
  </tr>
 </apex:repeat>

Edit1:
Managed to fix with @cropredy tips.

but now im am getting a new error when the field is outputField see code below complains about "syntax error )". Any insight

<p>Online</p>

<table border="1" cellpadding="1" cellspacing="1" style="text-align: left;">

    <tr>
        <th>Type</th>
        <th>Date</th>
        <th>Start Time</th>
        <th>End Time</th>
        <th>Location</th>
    </tr>

    <apex:repeat var="rx" value="{!relatedTo.SDI_Rep_Trainings_Relationship__r}">
        <tr>
            <td>
                <apex:outputText value="{!IF(rx.Type__c == 'Online', rx.Type__c, '')}" />
            </td>



            <td>
                <apex:outputText value="{0,date,MM/dd/yy}">

                    <apex:param value="{!IF(rx.Type__c == 'Online', rx.Date__c, '')}" />

                </apex:outputtext>
            </td>



            <td>
                <apex:outputField value="{!IF(rx.Type__c == 'Online', rx.Training_Start_Time__c, '')}" />
            </td>



            <td>
                <apex:outputField value="{!IF(rx.Type__c == 'Online', rx.Training_End_Time__c, '')}" />
            </td>



            <td>
                <apex:outputText value="{{!IF(rx.Type__c == 'Online', rx.Location__c, '')}}" />
            </td>



        </tr>

    </apex:repeat>

</table> ```

Best Answer

You have:

<apex:outputField value="{!IF(rx.Type__c == 'Online', rx.Training_Start_Time__c, '')}"

You can't do this -- apex:outputFields can't be dynamically specified in an IF block

Normally, you would use rendered= like this:

<apex:outputField value="{!rx.Training_Start_Time__c}"
    rendered="{!rx_Type__c = 'Online'}"/>
<apex:outputText value="" rendered={!NOT(rx_Type__c = 'Online')}"/>

I suspect you are trying to format a datetime value and that is why you are using outputField.

Note, normally, outputField displays a label + value

  • This SFDC Forum post asserts that when outputField is used outside of a pageBlockSection, the label will not display.
  • Alternatively, add the attribute label="" to the outputField to suppress
Related Topic