Monday, September 18, 2017

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

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....

Friday, August 25, 2017

Plugin Profiler Causing Problems

Working in Dynamics 365 doing plugin development was problematic yesterday.  I've seen more than one occasion now where I can't get a plugin to work properly and there is no obvious reason why.  It turned out that uninstalling and reinstalling the plugin profiler solution fixed the issue with no code change.

The profiler must be caching something......

I hope this helps someone else and I am not the only person seeing this wonky behavior!