function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
obrienobrien 

ELSE IF / OR clause in apex:page action

Hello,

 

I have a custom VF page that I want all user profiles to view with the exception of two profiles. I have tried using || and an Else If statement to accomplish this but I receive errors for both.

 

Below is what I am trying to accomplish:

 

<apex:page action="{!if($Profile.Name != 'Profile1' || $Profile.Name != 'Profile2', null, urlFor($Action.Case.Tab, $ObjectType.Case,null, true))}"
    standardController="case" extensions="extension" recordSetVar="cases" tabStyle="Case">

 

Can this be done or will I have to do this in the extension?

 

Thank you

 

bob_buzzardbob_buzzard

You should be able to use IF/ELSE type statements in the page action, as you are into merge syntax which can take formula functions and operators.  I've pasted your code into my dev org and it compiles fine - what error are you getting?

 

 

gaisergaiser

Assuming you want users with profiles "Profile1" and "Profile2" to be redirected to Cases tab and all other users to stay on your VF page. And also assuming that you actually have a custom controller extension class called extension - the only thing which you need to change is IF condition, swap OR with AND like so:

 

 

<apex:page action="{!if($Profile.Name != 'Profile1' && $Profile.Name != 'Profile2', null, urlFor($Action.Case.Tab, $ObjectType.Case,null, true))}"
    standardController="case" extensions="extension" recordSetVar="cases" tabStyle="Case">
</apex:page>