0

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> ```
2
  • 2
    Once you start a merge expression with {! - don't use any additional {! or ! within the enclosing {! ... } - your !rx.Type__c means NOT(Rx_Type__c)
    – cropredy
    May 27, 2022 at 17:38
  • Thanks it fixed and seems to work, but got some other error when the field is outputField, updated the post
    – Jon
    May 27, 2022 at 20:46

1 Answer 1

0

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
1
  • Thanks, rendered helped a lot I used that with a combination of output panel to conditionally display using the rendered option.
    – Jon
    May 31, 2022 at 14:08

You must log in to answer this question.

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