Id = [ID] 的帐户不存在
Account with Id = [ID] does not exist
我正在尝试从 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());
}
提前致谢!
您从 WhoAmIRequest 获得的用户 ID 属于系统用户实体,而不属于帐户实体。
oServiceProxy.Retrieve("systemuser", userid, new ColumnSet("fullname"));
我正在尝试从 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());
}
提前致谢!
您从 WhoAmIRequest 获得的用户 ID 属于系统用户实体,而不属于帐户实体。
oServiceProxy.Retrieve("systemuser", userid, new ColumnSet("fullname"));