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

page layout assignment

use case: i wish to assign 2 different page layouts on a custom object to 2 useres with same profile type.


When a new record is created on custom object and ownership is to a user A, another user B of same profile type is given read/write access to the record via apex sharing rule via a trigger, as this object is private.

Along with that i wish to add a seperate page layout to the user B so that both can have seperarte views for same record bases on there area of function.


code i using for sharing access

trigger MobjectSharingrule on Mobject__c (after insert) {

    List<Mobject__Share> MobjectShares  = new List<Mobject__Share>();

    for(Mobject__c Mobject :{

        Mobject__Share MobjectBUserShare = new Mobject__Share();
        MobjectBUserShare.ParentId = Mobject.Id;
        MobjectBUserShare.UserOrGroupId = Mobject.Mobject_Property_BUser__c;
        MobjectBUserShare.AccessLevel = 'edit';
        MobjectBUserShare.RowCause = Schema.Mobject__Share.RowCause.Suggested_Property_BUser__c;
    Database.SaveResult[] MobjectShareInsertResult = Database.insert(MobjectShares,false);

 1. is it possible?

2. do i have to assign the record type B to userB (with page layout B )


thank you

Hengky IlawanHengky Ilawan

I think you need to use record types.







I understand but normally when we use mutiple record types we assign the layouts with a combination of profiles.

Here i do not have that option as both user have same profile type. So same layout assigned by default. 

Also i want to perform this action within this trigger only.