如何在 CRM 365 中共享记录

我想在满足几个条件时分享我的记录,我可以用插件来做吗?我有我想分享的请求转移记录,所以当请求转移状态被提交时,我会在我的请求转移字段中将记录分享给我从仓库获得的用户。我可以用插件做到这一点吗?


if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)

{

  if(context.MessageName.ToUpper() == "UPDATE")

  {

    int requestStatus = transferImage.GetAttributeValue<OptionSetValue>("mjt_request_status").Value;

    if(requestStatus == 2)

    {

      EntityReference warehouse = transferImage.GetAttributeValue<EntityReference>("mjt_request_to ");


      ColumnSet columnSet = new ColumnSet(true);

      var warehouses = service.Retrieve("msdyn_warehouse ", warehouse.Id, columnSet);


      if (warehouses.Attributes.ContainsKey("mjt_administrator"))

      {

        adminstrator = warehouses.GetAttributeValue<EntityReference>("mjt_administrator");

      }


      if(adminstrator != null)

      {

      }


    }

  }

}

我的代码刚刚结束,我从转移请求中获取了管理员,然后我不知道如何将请求共享给我的用户。


慕桂英4014372
浏览 244回答 1
1回答

呼唤远方

你必须使用GrantAccessRequest来做到这一点。// Grant the user read access to the record.var grantAccessRequest1 = new GrantAccessRequest{&nbsp; &nbsp; PrincipalAccess = new PrincipalAccess&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; AccessMask = AccessRights.ReadAccess,&nbsp; &nbsp; &nbsp; &nbsp; Principal = adminstrator&nbsp; &nbsp; },&nbsp; &nbsp; Target = transferReference};serviceProxy.Execute(grantAccessRequest1);
打开App,查看更多内容
随时随地看视频慕课网APP