Posted in CRM, Plugin

Sharing a record in ms CRM Plugin

Sharing a record in ms CRM Plugin :

sharing a record in ms crm through Plugin with Read and Write acess.

Entity MobReviewer = (Entity)context.InputParameters["Target"];
 Guid moblookupid = ((EntityReference)MobReviewer.Attributes["ntuc_mobid"]).Id;
 Guid userlookupid = ((EntityReference)MobReviewer.Attributes["ntuc_user"]).Id;
 var recordRef = newEntityReference(((EntityReference)MobReviewer.Attributes["ntuc_mobid"]).LogicalName, moblookupid);
 var UserRef = new EntityReference(((EntityReference)MobReviewer.Attributes["ntuc_user"]).LogicalName, userlookupid);

 

Principal – for whom we are sharing  the record.

Target – Which record we are sharing.

//Sharing a RECORD
 GrantAccessRequest request = new GrantAccessRequest
 {
 PrincipalAccess = new PrincipalAccess
 {
 AccessMask = AccessRights.ReadAccess | AccessRights.WriteAccess,
 Principal = UserRef
 },
 Target = recordRef
 };
 service.Execute(request);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s