2

I'm a Visualforce newbie so forgive me if my question comes across as a bit ignorant...

I'm trying to render a Visualforce page based on specific conditions. I got it to work with one condition but when I add conditions to the statement, it doesn't work.

Something like this works:

<apex:outputpanel rendered="{!IF(Opportunity.StageName == 'Closed Won', true, false)}"></apex:outputpanel>

Something like this doesn't work:

<apex:outputpanel rendered="{!IF(Opportunity.StageName =='Closed Won' && Opportunity.Approval_Status__c != 'Approved', true, false)}"</apex:outputpanel> 

What is wrong with my code?

5

That should work, to be honest, but realistically, you don't need the IF statement--a Boolean value is already a Boolean value, so you don't need another Boolean value.

rendered="{!AND(Opportunity.StageName='Closed Won', Opportunity.Approval_Status__c!='Approved')}"

Sometimes the & has a problem, since Visualforce is technically XML, so using AND can help prevent this problem.

  • Amazing! Using the !AND worked perfectly. – sfdc11 Dec 26 '19 at 19:55

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.