We're using MSCRM Dynamics, and we're trying to get all the children of a particular user. (A user has a manager, the manager has 'children'.) The following works, but throws an exception if the user has no children. This seems logical at first, maybe, but why not just return an empty set? And of all things, it throws a SoapException with a cryptic message of "Invalid Argument" (which is wrong) and the .Detail.InnerText says "0x80040203 The value passed for ConditionOperator.In is empty Platform". If you look at the corresponding Response class, it has a collection -- why not just leave it empty?
// 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));
}