dynamics 365 資料共享
阿新 • • 發佈:2020-07-17
一、共享
AccessRights.ReadAccess:讀
AccessRights.WriteAccess:寫
AccessRights.AppendAccess:追加
AccessRights.AppendToAccess:追加到
AccessRights.AssignAccess:分派
AccessRights.CreateAccess:建立
AccessRights.DeleteAccess:刪除
AccessRights.ShareAccess:共享
/// <summary> /// 共享記錄 /// </summary> /// <param name="teamOruser">要共享給使用者或者團隊</param> /// <param name="entiy">要共享的記錄</param> private static void Shared(IOrganizationService service, EntityReference teamOruser, EntityReference entity) {
GrantAccessRequest grantAccessRequest = new GrantAccessRequest { Target= entity, PrincipalAccess = new PrincipalAccess { Principal = teamOruser, AccessMask = AccessRights.ReadAccess | AccessRights.WriteAccess | AccessRights.AppendAccess | AccessRights.AppendToAccess } }; service.Execute(grantAccessRequest); }
二、撤銷團隊或使用者共享
public void ColseShared(IOrganizationService service, EntityReference teamOruser, EntityReference entity) { var revokeUserAccessReq = new RevokeAccessRequest { Revokee = teamOruser,//需要撤銷共享的團隊或使用者 Target = entity,//需要撤銷的目標實體 }; service.Execute(revokeUserAccessReq); }