web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

RetrieveMultiple Using Newest Dynamics 365 SDK Gives Weird Behavior When Filtering on StateCode

Jamie Miley Profile Picture Jamie Miley 2,060
Why in the world would it now be necessary to search using a conditionexpression on statecode by the strings "Active" or "Inactive"  instead of just taking the integer values of the optionset when performing a retrievemultiple request in a custom workflow activity.




 if (targetChildStateCode == 0)
{
strTargetChildStateCode = "Active";
}
else if (targetChildStateCode == 1)
{
strTargetChildStateCode = "Inactive";
}
int targetChildStatusReason = TargetChildStatusReason.Get(activityContext);
tracingService.Trace("targetChildStateCode: " + targetChildStateCode.ToString());
tracingService.Trace("targetChildStatusReason: " + targetChildStatusReason.ToString());
tracingService.Trace("got parameters");
tracingService.Trace("defined criteria and paging info");

RetrieveMultipleRequest rmr = new RetrieveMultipleRequest();
RetrieveMultipleResponse resp = new RetrieveMultipleResponse();

QueryExpression query = new QueryExpression()
{
EntityName = childEntityName,
ColumnSet = new ColumnSet(true),
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = childLookupAttributeToParent,
Operator = ConditionOperator.Equal,
Values = { primaryEntityId.ToString() }
},
new ConditionExpression
{
AttributeName = "statecode",
Operator = ConditionOperator.NotEqual,
Values = { strTargetChildStateCode }
}
}
}
};
 


-head scratcher....

This was originally posted here.

Comments

*This post is locked for comments