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
Suraj GharatSuraj Gharat 

How to allow only related users to edit the record ?

Hi All,
I have a custom object with four lookup fields to User.
All records of this object should be readable to all org users. (This could be done by setting OWD to public readonly)
And each record of this object should be editable to only those four users who are linked via four lookup fields.
These four users could be any users and vary one record to another.
How can I implement this without asking my users to manually share their records.

Can anybody help me?
Best Answer chosen by Suraj Gharat
Sonam_SFDCSonam_SFDC
Hi Suraj,

What you can possibily do here is create a custom button (to share the record with lookup specified users) through which call a VF page and controller class and share the record through that class -
  1. http://sfdc.arrowpointe.com/2009/01/08/invoke-apex-from-a-custom-button-using-a-visualforce-page/
  2. http://shivasoft.in/blog/salesforce/apex-based-sharing-in-salesforce/