I have written a plugin that grants access to a user for an account record as below
GrantAccessRequest grantAccessRequest = new GrantAccessRequest
{
PrincipalAccess = new PrincipalAccess
{
AccessMask = AccessRights.ReadAccess | AccessRights.WriteAccess | AccessRights.AppendAccess | AccessRights.AppendToAccess,
Principal = consultant
},
Target = new EntityReference(account.LogicalName, account.Id)
};
The problem is this only works sometimes. When I check the audit log on records it does not work on, it says that the record has been shared with the correct user, however the user still cannot see the record.
Has anyone else run into this inconsistency with sharing records? If so how did you solve it?