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
carmantcarmant 

Page Layout assignment not via Profiles

Hi,

 

Is there any way to assign page layouts via APEX or otherwise?

 

Use case:

  • We wish to limit which information/fields/related lists users view on the Account object, depending on the USER POSITION and the TYPE OF ACCOUNT
  • I'm open to suggestions on how we define their "position" - it could be via Groups, or via an additional parameter we create against their user record.
  • The TYPE of account is already defined by a field on the Account record (we dont use record types)
  • Eg. User clicks Account, code runs to check their position vs the type of account they are trying to view
  • If user is Position A, they are trying to view Account Type A, send to Page Layout A. 
    If  user is Position B, they are trying to view Account type A, send to Page Layout B
    If user is Postion A or B, they are trying to view Acount Type C, sent to Page Layout C
  • Would rather leverage Page Layouts rather than build VF pages, but thats still a possibility if its the only way.

 

Why I don't want to use profiles?

I know this could partly be achieved via profiles / page layout assignment. BUT we already have around 50 profiles, its a nightmare to manage already, and I would rather explore other methods of achieving this, as opposed to introducing a whole pile more profiles. ALso this would create "blanket" rules - eg. user of position (Profile) A would always see page layout A - we need this to be dynamic based on not only their position, but the TYPE of account that user is trying to view.

 

Any ideas or pointers greatly appreciated!

 

Thanks,

Tom