+ Start a Discussion
SKiranSKiran 

Page overriding limiting to non admin users.

Hi, I am able to override the custom page for edit and new actions of object. Thats great. But I want that admin to be able to create those records with standard page and with the custom page that I have overriden for new and edit. Is there any way to restrict this overriding to non admin users.

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9

There is definately a way out!

So if you want to do a selective overriding you have to look for URL params. There are some URL params available that can remove the overriding and will show you the standard page.

 

So Actual Step will be

  • Create a VF page and override the EDIT. Now in the controller you will be checking if its a ADMIN profile If yes you will redirect the USER to the edit page and by adding "nooverride=1" so the URL will be like "/RecordId?nooverride=1".

 

All Answers

Satish_SFDCSatish_SFDC
Are you using a Standard Controller.
If yes, then you can set the Object permissions for all profile to just 'Read'. This way everyone can see the page but only sys admins can create/edit records.

If you are using a custom controller, you will have to check for permissions before creating records.
Use the describe statements to check for permissions before creating records.

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_fields_describe.htm


Regards,
Satish Kumar
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.
SRKSRK
As far as i can understand you question is that

you want to open standard page for admin users and custom page for non admin user
m i rite ??

please let me know if my understand is correct if that the case i can help you on that :)
SKiranSKiran
@Satish_SFDC, yes I am using standard controller, but I other user creates records for that object. So I cant give them only read access. I need to give them edit and create access. Is there any way by which by profile name we can get standard edit page for admin and custom for other users.Any pointers would be of great help thanks in advance.
SKiranSKiran
@SRK, yes that exactly what I wanted. Is there any way?
Avidev9Avidev9

There is definately a way out!

So if you want to do a selective overriding you have to look for URL params. There are some URL params available that can remove the overriding and will show you the standard page.

 

So Actual Step will be

  • Create a VF page and override the EDIT. Now in the controller you will be checking if its a ADMIN profile If yes you will redirect the USER to the edit page and by adding "nooverride=1" so the URL will be like "/RecordId?nooverride=1".

 

This was selected as the best answer
SKiranSKiran
@Avidev9 ..
Great man!! Thanks it works like charm.