【问题标题】:Account with Id = [ID] does not existID = [ID] 的帐户不存在
【发布时间】:2019-11-28 10:31:00
【问题描述】:

我正在尝试从 Dynamics CRM 中检索我自己的姓名,但在检索过程中我不断收到此消息。 (代码通过 WhoAmIRequest 成功地给了我我的用户 ID) System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault] Id = [ID] 的帐户不存在。

   IOrganizationService oServiceProxy;
            try
            {
                //Create the Dynamics 365 Connection:
                CrmServiceClient oMSCRMConn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient("AuthType=Office365;Username=_username;Password=_password;URL=https://hrrevuat.crm4.dynamics.com/;");

                //Create the IOrganizationService:
                oServiceProxy = (IOrganizationService)oMSCRMConn.OrganizationWebProxyClient != null ?
                        (IOrganizationService)oMSCRMConn.OrganizationWebProxyClient :
                        (IOrganizationService)oMSCRMConn.OrganizationServiceProxy;
                if (oServiceProxy != null)
                {


                    //Get the current user ID:
                    Guid userid = ((WhoAmIResponse)oServiceProxy.Execute(new WhoAmIRequest())).UserId;



                    if (userid != Guid.Empty)
                    {
                        Console.WriteLine("Connection Successful!");
                        oServiceProxy.Retrieve("account", userid, new ColumnSet("name"));
                    }
                }
                else
                {
                    Console.WriteLine("Connection failed...");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error - " + ex.ToString());
            }

提前致谢!

【问题讨论】:

    标签: c# dynamics-crm dynamics-crm-online dynamics-crm-365


    【解决方案1】:

    您从 WhoAmIRequest 获得的用户 ID 属于 systemuser 实体,而不是帐户实体。

    oServiceProxy.Retrieve("systemuser", userid, new ColumnSet("fullname"));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-14
      • 2021-06-10
      • 1970-01-01
      • 1970-01-01
      • 2019-04-14
      相关资源
      最近更新 更多