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
Leandro Santillan 6Leandro Santillan 6 

How to send an email to the user who got a record shared with him?

Hello,
I would like to create a trigger that sends an email to the user letting him/her know that a record(and a link to that record) has been shared. I wrote a trigger to send an email when a record is deleted but I don't know how to modify that one so it works for what I am trying to accomplish. Any piece of code would be highly appreciated.
Yes, I am sort of new to coding, not to Salesforce..
Thank you.
BalajiRanganathanBalajiRanganathan
I dont think trigger will be executed when the record is shared. For each object there is a share table.
You could write a batch job to get the records from sharetable based on lastmodifieddate and send out email to the user. you can schedule the batch to run hourly or daily.

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_bulk_sharing_creating_with_apex.htm