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
Janno RipJanno Rip 

Vary content of Visualforce Page and underlying data from apex class depending on profile

Hello Developers,

I have a question regarding the possibilty of having a visualforce page that shows different content depending on the User Profile. The varying content is nurtured by different apex classes.

Right now my solution looks like this: 2 Apex Classes and 2 VF Pages that are both on the layout:

Apex Class A delivers data for VF Page 1
Apex Class B delivers data for VF Page 2

User-added image
What I want to achieve is the following example:

If I am an Administrator I want to display VF Page 1 with the data delivered from apex class A

If I am a Sales Agent I want to display VF Page 2 with the data delivered from apex class B
User-added image
Would it be 1 Apex Class with 1 VF Page where? Or would it be 2 Apex Class and 1 VF Page? 

I am already able to show different VF Page dependent on the profile, but I am struggling with the classes because they also need to change since its different data that should be displayed.

Maybe some of you have an idea how to tackle this

Thanks in Advance

Jan