+ Start a Discussion

Record sharing through Trigger

Hi everyone, 

i am new to writing triggers.

i need a small help from you guys, let me explain the scenario.


we have 2 custom objects under accounts. custum object 1 is Master detail to Account, custom object 2 is look up to account and custom object 1. 


1. we have 3 fields on object 1, status, user and owner custom fields.

2. we have object 2 as a related list in object 1 record.

3. in org wide setting i have set object 2 as private permissions to create a sharing obejct for object 2.


i need to write a trigger on object 1 or object 2, when the status is set to true on object 1, we have to give the access to object 2 for user and owner fields on object 1. this trigger has to fire only when the status is true.

and also whenever the user or owner values are changed i need to give the access to old users aswell as new users.


can anyone help me out with some sample code.


thanks in advance.


Best Answer chosen by Admin (Salesforce Developers) 

Please go through this link



Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.