私たちはMSCRM Dynamicsを使用しています。私たちは特定のユーザーのすべての子どもを取得しようとしています。 (ユーザーにはマネージャーがあり、マネージャーには 'children'があります。)以下は機能しますが、ユーザーに子がない場合は例外がスローされます。最初は論理的に思えるかもしれませんが、空のセットを返さないのはなぜですか?そして、すべての事の中で、 "Invalid Argument"(間違っている)の潜在的なメッセージでSoapExceptionをスローし、.Detail.InnerTextは "0x80040203 ConditionOperator.Inに渡された値が空のPlatform"と言います。対応するResponseクラスを見ると、そのクラスにはコレクションがあります。CRM:子どもが子どもに子どもを投げないようにする
// 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));
}
私たちは現在、すべてのSoapExceptionsを飲み込んでいますが、私は本当に貧弱な解決策であると感じています。より良い解決策が見つからない場合、私はこのケースをよりよく分けることができるかどうかを調べるために式を掘り下げなければなりません。 – Thanatos