+ Start a Discussion
MayeUPAEPMayeUPAEP 

Override Page

I need your help, I'm overriding the "New" and "Edit" button of Accounts deppending of the profile of the user.

For some profiles there will be showed x page (I'have developed that and that's ok) but the problem is when I want for some users to show the standard "new" or "edit" salesforce page.  How do I get that!!??

 

I use this code to show x page (I don't have problems here)

 

 

if (USER_PROFILE == '00e40000000wksvAAA') { PageReference PageRef= new PageReference('/apex/pagex'); PageRef.setredirect(true); PageRef.getParameters().put('id', ID); return pageRef; }

 

 I use this other when a user doesn't have access to this option (I don't have problems here)

 

 

else return null;

 

 What do i need do if I want that certain profile goes to the standard salesforce page to add or edit a record???

 

 

 

Rajesh ShahRajesh Shah

Check the below code. I implemented something similar. Here, the important part is to user nooverride=1. If that is not used, you will again redirected to the override edit page and thus run in an infinite loop.

 

PageReference redirectURL;
if(newRecType)
redirectURL = new PageReference('/apex/myEditPage?' + caseId + '&action=Edit' + '&retURL=%2F' + caseId);
else
redirectURL = new PageReference('/500/e?id=' + caseId + '&nooverride=1' + '&retURL=%2F' + caseId);

 

 The above is for edit url. You would get a similar url for new. Append the nooverride=1 to that too.

 

Message Edited by Rajesh Shah on 02-11-2010 01:42 PM
Anil Kumar SinghAnil Kumar Singh

Thanks a lot for posting this!!!! It's working fine.