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
YallDevYallDev 

Insufficient Privileges for custom page

I have looked at most examples that fall into the Insufficient Privileges category and I have found none that is identical to my situation.

 

What I did is overide the standard contact page (View) with my custom visualforce page.  I can allow who see's this page and this is not my problem.

 

Is their a way that I can load the normal Contact View  to uses who do not have permission ?  Instead I always get the error.

 

Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.
Best Answer chosen by Admin (Salesforce Developers) 
SFDC_VikashSFDC_Vikash

Hi,

 

Directly you cannot do this but you get this with the help of custom setting.

 

First of all you have to create a Hierarchial custom setting, then create a checkbox field on that with default value unchecked and at last check i.e set true this checkbox for the profiles to whom you want to override the view page by managing the custom setting.

 

And add a method to extension of custom view page as :

 

  public PageReference redirectToStandard(){
      Override_view_page__c overridePage = Override_view_page__c.getInstance();
      if(overridePage.Override_View_Page__c != null && overridePage.Override_View_Page__c == false){
        return new PageReference('/' + contact.Id + '?nooverride=1');
      }
      return null;
    }

 And call this method on your custom view page as :

 

<apex:page standardController="Contact" extensions="contactViewExt" action="{!redirectToStandard}">
  //Details for contact
</apex:page>

 It will work for you.

 

Please mark it as solution if it solved your problem so that others can use this.

All Answers

Richie DRichie D

Hi,

 

I don't believe you can do this. If you override the view page for an object this will apply to all users - regardless of their permissions on the visualforce page.

 

Regards,
Rich.

SFDC_VikashSFDC_Vikash

Hi,

 

Directly you cannot do this but you get this with the help of custom setting.

 

First of all you have to create a Hierarchial custom setting, then create a checkbox field on that with default value unchecked and at last check i.e set true this checkbox for the profiles to whom you want to override the view page by managing the custom setting.

 

And add a method to extension of custom view page as :

 

  public PageReference redirectToStandard(){
      Override_view_page__c overridePage = Override_view_page__c.getInstance();
      if(overridePage.Override_View_Page__c != null && overridePage.Override_View_Page__c == false){
        return new PageReference('/' + contact.Id + '?nooverride=1');
      }
      return null;
    }

 And call this method on your custom view page as :

 

<apex:page standardController="Contact" extensions="contactViewExt" action="{!redirectToStandard}">
  //Details for contact
</apex:page>

 It will work for you.

 

Please mark it as solution if it solved your problem so that others can use this.

This was selected as the best answer
Richie DRichie D

Hi Vikash,

 

That is a great solution. I'll remember that and use it quite often. 

 

Learn something new everyday!

 

Regards,

Rich.

YallDevYallDev

Hi Vikash

 

Thanks So much you saved my day, This is definetly the solution here.

 

Thanks Again

 

Jamil