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
djfubardjfubar 

including an if statement to the page action

Hi All,

 

On my custom "add opportunity product" VFpage I currentyl call a method in my custom controller (priceBookCheck) in the page action.

 

This works fine but I now need to add an if statment to the page action to ensure that the system administrator can only run the new VF page.

 

The following works:-

action="{!if(($Profile.Name == 'System Administrator'),
null,
urlFor($Action.OpportunityLineItem.AddProduct, Opportunity.Id,
null, true))}">

 

But I need to call the priceBookCheck method when the if statement is true. I have tried the following but get a syntax error

 

action="{!if(($Profile.Name == 'System Administrator'),
{!priceBookCheck},
urlFor($Action.OpportunityLineItem.AddProduct, Opportunity.Id,
null, true))}">

 

Does anyone know how to accompkish my goal?

 

Thanks

Prad@SFDCPrad@SFDC

Hi,

 

You can check this condition in apex class by calling a action.Like

Get the User profile name using Query

 

If(UserProfileName = 'System Administrator')

{

// Do this

}

else

{

//Do this

}

 

Dis this answer help you.If not then let me know the Issue.

djfubardjfubar

Hi,

 

An infinite loop occurs if I do that as my “else” clause will redirect to the standard opp product screen which is overridden by this VF page.

 

Hope that makes sense


 

Prad@SFDCPrad@SFDC

Hi,

 

Try the nooverride=false in URL in else condition.

So this will not call your VF Page again.

 

Like

 

https://ap1.salesforce.com/001/o?nooverride=false

 

Hope this wil help you.