-1

I need to display a banner on classic page when a condition is true.

When a lookup field (referencing to Account) has 'abc' the banner should display on classic. I have added the condition on VF page but it does not work. Can I reference the lookup directly ?

<apex:outputPanel rendered="{!object.lookupfield__c=='abc'}">
    <div id="someiddiv"/>
</apex:outputPanel>

2 Answers 2

0

The object.lookupfield__c is a reference to the Id that's stored in that lookup field. Assuming you want to check if the Name of the looked up record has abc in it you would need to use object.lookupfield__r.Name.

0

In your code, it seems like you are directly referencing the lookup field "lookupfield__c" in the condition for rendering the apex:outputPanel. However, this won't work as lookup fields are not directly accessible in Visualforce pages.

To display the banner based on the value of the lookup field, you will need to first retrieve the record that the lookup field references and then check the value of the desired field in the referenced record. Here's an example:

<apex:pageBlock>
    <apex:pageBlockSection>
        <apex:outputPanel rendered="{!object.lookupfield__r.Name == 'abc'}">
            <div id="someiddiv"/>
        </apex:outputPanel>
    </apex:pageBlockSection>
</apex:pageBlock>

Note: Replace object with the actual name of the object that contains the lookup field. Also replace Name with the actual name of the field in the referenced object that you want to check.

You must log in to answer this question.

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