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
Long TruongLong Truong 

Multiple Visualforce page layout for a Custom Object

I have created a Custom Object called Subgrantee Profile, using the SubgranteeProfileController. There's a Visuaforce page (let's cal it page 1) that renders the fields under different tabs. I want to clone this Visualforce page into Visualforce page 2, delete some tabs, and assign it to a specific profile A.

I have changed the setting under:
- Profile > Enable Visualforce Page
- changed the Page Layout Assignment
- changed the Security setting of the Visualforce Page 2.

But when I log in as a profile A user, I can only see page 1. The only way I can make page 2 show, is to go Create > Object > Subgrantee Profile > Buttons, Links, and Action > View, and change the content source to page 2. But this change the view to page 2 for ALL profiles, which I don't want.

So in short, my question is: can I assign 2 visualforce pages of the same custom object to different profiles?

Thanks,
Best Answer chosen by Long Truong
Peter_sfdcPeter_sfdc
Does it have to be two different pages? User profile information (of the logged in user) is accessible from the UserInfo object in Apex and I'm pretty sure the $Profile global variable in Visualforce itself. 

You could use this to change the UI itself, or perform a redirect to one or the other page (if it absolutely had to be two pages). 

The accepted answer on this Salesforce Stack Exchange question does a good job of showing the redirect option. 

http://salesforce.stackexchange.com/questions/5716/override-new-button-and-redirect-to-vf-page-based-on-pagelayout-assignment


All Answers

Peter_sfdcPeter_sfdc
Does it have to be two different pages? User profile information (of the logged in user) is accessible from the UserInfo object in Apex and I'm pretty sure the $Profile global variable in Visualforce itself. 

You could use this to change the UI itself, or perform a redirect to one or the other page (if it absolutely had to be two pages). 

The accepted answer on this Salesforce Stack Exchange question does a good job of showing the redirect option. 

http://salesforce.stackexchange.com/questions/5716/override-new-button-and-redirect-to-vf-page-based-on-pagelayout-assignment


This was selected as the best answer
Long TruongLong Truong
Thank you, this answered my question.