+ Start a Discussion
finalistfinalist 

Overriding [New] using Controller Extension returns 'insufficient privileges'

I'm looking to do something similar to the Redirect by Record Type solution posted last fall, in which we want to send certain Opportunity Record Type creates/edits to our custom Visualforce page and the rest to the standard pages.

 

Before I get to the point of determining which direction to go, I wrote a very basic Opportunity controller extension to display the RecordTypeId.

 

If I log in as a User with less than Administrator privileges, however, I get an 'insufficient privileges' error and the page doesn't load (and no debug log is generated).

 

My extension is not written 'with sharing', so I should be able to do whatever I need to there, no?  (apparently not).  

 

Here's the code for my extension, and the page (they're both quite short):

 

 

public class SelectOppRecordType_Extension {

private final Opportunity opp;
	
public SelectOppRecordType_Extension(ApexPages.StandardController stdController) {
	opp = (Opportunity)stdController.getRecord();
	String rtName;
		
	if(opp.RecordTypeId <> null){
		RecordType rt = [Select Name from RecordType where Id = :opp.RecordTypeId];
		rtName = rt.Name;
		System.debug('========== RecordType Name = ' + rt.Name);
		
	} else {
		rtName = 'No RecordTypeId to see';
	}
	
	System.debug('====== sName = ' + rtName);
		
    }
		
}

 

 

And the page (The 'why have an inputHidden and an outputText for the same value..?' is not germane, really; trust me) :

 

<apex:page standardController="Opportunity" extensions="SelectOppRecordType_Extension">
	<apex:form >
		<apex:outputPanel >
			<apex:inputHidden id="recordTypeId" value="{!Opportunity.RecordTypeId}" />
			<apex:outputText value="{!Opportunity.RecordTypeId}" />
		</apex:outputPanel>
	</apex:form>
</apex:page>

 

 

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

did you provide access to the page to the required profiles?

All Answers

aballardaballard

did you provide access to the page to the required profiles?

This was selected as the best answer
finalistfinalist

<Maxwell Smart>The old 'update the Security settings to allow those profiles to see your custom page, dummy' trick.  I saw that coming.</Maxwell Smart>

 

never mind...

finalistfinalist

Quick turnaround, aballard!  Thanks!  I'll take care of the *headdesk* from here.