我们正在使用 MSCRM Dynamics,并且我们正在尝试获取特定用户的所有孩子。(用户有一个经理,经理有“孩子”。)以下工作,但如果用户没有孩子,则会引发异常。起初这似乎是合乎逻辑的,也许,但为什么不只返回一个空集呢?最重要的是,它会抛出一个带有“无效参数”(这是错误的)的神秘消息的 SoapException,并且 .Detail.InnerText 显示“0x80040203 传递给 ConditionOperator.In 的值是空平台”。如果您查看相应的 Response 类,它有一个集合——为什么不把它留空呢?
// Create the request object.
RetrieveAllChildUsersSystemUserRequest retrieve =
new RetrieveAllChildUsersSystemUserRequest();
// Create the column set object that indicates the fields to be retrieved.
ColumnSet cols = new ColumnSet();
cols.EntityName = "systemuserid";
// Set the column set.
retrieve.ColumnSet = cols;
// Set the ID of the parent user.
retrieve.EntityId = context.UserId;
RetrieveAllChildUsersSystemUserResponse retrieved =
new RetrieveAllChildUsersSystemUserResponse();
/// Execute the request.
/// Catches if user does not have children
/// (Check to see if user is manager)
try
{
retrieved =
(RetrieveAllChildUsersSystemUserResponse)crmService.Execute(retrieve);
}
catch (System.Web.Services.Protocols.SoapException e)
{
throw new Exception(string.Format("{0}", e.Detail.InnerText));
}