Answered by:
CRM 2011: Sending an E-mail on sharing record

Question
-
Hi all, I have a requirement where I need notify a user when a record is shared with him, I can't find out how to do it out of the box.
I tried to do it using workflows, java script and plugins
Please advise..
Monday, July 9, 2012 12:36 PM
Answers
-
Hi Mostafa,
You can use following lines of code to get the user to whom the record is getting shared.
EntityReference sysUser = ((PrincipalAccess)context.InputParameters["PrincipalAccess"]).Principal;
Guid sysUserId = sysUser.Id;PS: if we have shared a record to multiple users(lets say 2 users) then the plugin will be triggered multiple times(twice).
Hope it helps...!! :)
Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"
- Proposed as answer by Vikranth Pandiri Tuesday, July 10, 2012 8:25 AM
- Marked as answer by Andrii ButenkoMVP, Moderator Friday, July 20, 2012 7:50 AM
Tuesday, July 10, 2012 8:25 AM -
Hi Mostafa,
Register your plugin on "GrantAccess" message.
Let's say"Message - GrantAccess" and "Entity - lead" then your plugin will be triggered on sharing of the lead entity record.
Hope it helps....!! :)
Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"
- Proposed as answer by Vikranth Pandiri Monday, July 9, 2012 5:56 PM
- Marked as answer by Andrii ButenkoMVP, Moderator Friday, July 20, 2012 7:50 AM
Monday, July 9, 2012 5:53 PM
All replies
-
Hi Mostafa,
"GrantAccessRequest" is used to share a record. So, I believe you can use "GrantAccess" Message to register your plugin. Give a try and let us know.
Hope it helps..!! :)
Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"
Monday, July 9, 2012 1:13 PM -
Hi Mostafa,
"GrantAccessRequest" is used to share a record. So, I believe you can use "GrantAccess" Message to register your plugin. Give a try and let us know.
Hope it helps..!! :)
Monday, July 9, 2012 2:12 PM -
Hi Mostafa,
Register your plugin on "GrantAccess" message.
Let's say"Message - GrantAccess" and "Entity - lead" then your plugin will be triggered on sharing of the lead entity record.
Hope it helps....!! :)
Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"
- Proposed as answer by Vikranth Pandiri Monday, July 9, 2012 5:56 PM
- Marked as answer by Andrii ButenkoMVP, Moderator Friday, July 20, 2012 7:50 AM
Monday, July 9, 2012 5:53 PM -
Looks great :)
But how to get the users to whom the record is shared ?
Monday, July 9, 2012 6:38 PM -
Hi Mostafa,
You can use following lines of code to get the user to whom the record is getting shared.
EntityReference sysUser = ((PrincipalAccess)context.InputParameters["PrincipalAccess"]).Principal;
Guid sysUserId = sysUser.Id;PS: if we have shared a record to multiple users(lets say 2 users) then the plugin will be triggered multiple times(twice).
Hope it helps...!! :)
Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"
- Proposed as answer by Vikranth Pandiri Tuesday, July 10, 2012 8:25 AM
- Marked as answer by Andrii ButenkoMVP, Moderator Friday, July 20, 2012 7:50 AM
Tuesday, July 10, 2012 8:25 AM