public void GrantAccess(IOrganizationService service,string entityName,Guid id,Guid userId)
{
GrantAccessRequest ga = new GrantAccessRequest()
{
PrincipalAccess = new PrincipalAccess() {
Principal = new EntityReference("systemuser",userId),
AccessMask = AccessRights.ReadAccess | AccessRights.AppendToAccess
},
Target = new EntityReference(entityName,id)
};
service.Execute(ga);
}
{
GrantAccessRequest ga = new GrantAccessRequest()
{
PrincipalAccess = new PrincipalAccess() {
Principal = new EntityReference("systemuser",userId),
AccessMask = AccessRights.ReadAccess | AccessRights.AppendToAccess
},
Target = new EntityReference(entityName,id)
};
service.Execute(ga);
}