Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Condition operator 'NotNull' requires that no values are set. Values.Length: 1

(0) ShareShare
ReportReport
Posted on by 311

Hi,

I'm deriving new workflow step from an existing Codeplex solution (https://msdyncrmworkflowtools.codeplex.com) step "Update Child Records").  I'm trying to add possibility of filtering child entities that will be updated. 

Therefore I added three new parameters for condition attribute,  operator and value. I created new function UpdateChildRecordsConditional (derivation from UpdateChildRecords), with three parameters above and with additional part that processes three new parameters.

My main changes are marked red bellow in source code.

It works OK when I specify an ConditionOperator that requires vaule (e.g. attribute="name"; operator="Equal"; value = "something").

!!!! But, when I specify condition that doesn't require value (e.g. attribute="name"; operator="NotNull"), retrieveMultiple raises the exception "Condition operator 'NotNull' requires that no values are set. Values.Length: 1".

I checked it in CRM 2016 on premise, online and Dynamics 365. Of course I checked the Query.Criteria.Values for the last part and it contains 0 values. I also debugged it and verified that red lines are executed.

Here is the source code(this code might not be valid for some of attribute types).

///////// Code Begin

public void UpdateChildRecordsConditional(string relationshipName, string parentEntityType, string parentEntityId
            , string parentFieldNameToUpdate, string setValueToUpdate, string childFieldNameToUpdate
            , string conditionAttribute, string conditionOperator, string conditionValue)
{

// here comes original code  

//....

// I added/changed this:

              QueryExpression query = new QueryExpression
            {
                EntityName = childEntityType,
                Criteria = new FilterExpression
                {
                    Conditions =
                {
                    new ConditionExpression
                    {
                        AttributeName = "statecode",
                        Operator = ConditionOperator.Equal,
                        Values = {0}
                    }
                    ,new ConditionExpression
                    {
                        AttributeName = childFieldNameToUpdate,
                        Operator = ConditionOperator.NotEqual,
                        Values = {valueToUpdate}
                    }
                    , new ConditionExpression
                    {
                        AttributeName = childEntityFieldName,
                        Operator = ConditionOperator.Equal,
                        Values = {parentEntityId}
                    }
                    , new ConditionExpression
                    {
                        AttributeName = conditionAttribute,
                        Operator = co,
                        Values = {conditionValue}
                    }
                }
                }
            };
          
            ConditionOperator co = (ConditionOperator)Enum.Parse(typeof(ConditionOperator), conditionOperator);        
            if (conditionAttribute != null && conditionAttribute != "")
            {
                if (conditionValue != null && conditionValue != "")
                {
                    query.Criteria.AddCondition(new ConditionExpression
                        {
                            AttributeName = conditionAttribute,
                            Operator = co,
                            Values = { conditionValue }
                        });
                }
                else
                {
                     query.Criteria.AddCondition(new ConditionExpression(conditionAttribute, co));

                   // same with query.Criteria.AddCondition(new ConditionExpression(conditionAttribute, co, null));
                }
            }

            EntityCollection retrieved = service.RetrieveMultiple(query);

...

}

////////// Code End

*This post is locked for comments

  • Nikica Profile Picture
    Nikica 311 on at
    RE: Condition operator 'NotNull' requires that no values are set. Values.Length: 1

    But still doesn't work. Even I now don't have twice the condition. I implemented this check in a loop that later processes the result, but would like not to fetch it from server.

  • Nikica Profile Picture
    Nikica 311 on at
    RE: Condition operator 'NotNull' requires that no values are set. Values.Length: 1

    Actually, it looks like I used "    Operator = co," twice. Once where all other values are set (black font). Once in the end (red).

    The error could be the blue part.

    ////////////////////////////////////////////////////////////////////

    , new ConditionExpression
                        {
                            AttributeName = conditionAttribute,
                            Operator = co,
                            Values = {conditionValue}
                        }
                    }
                    }
                };
              
                ConditionOperator co = (ConditionOperator)Enum.Parse(typeof(ConditionOperator), conditionOperator);        
                if (conditionAttribute != null && conditionAttribute != "")
                {
                    if (conditionValue != null && conditionValue != "")
                    {
                        query.Criteria.AddCondition(new ConditionExpression
                            {
                                AttributeName = conditionAttribute,
                                Operator = co,
                                Values = { conditionValue }
                            });
                    }
                    else
                    {
                         query.Criteria.AddCondition(new ConditionExpression(conditionAttribute, co));

                       // same with query.Criteria.AddCondition(new ConditionExpression(conditionAttribute, co, null));
                    }
                }

                EntityCollection retrieved = service.RetrieveMultiple(query);

    ...

    }

    ////////// Code End

  • Nikica Profile Picture
    Nikica 311 on at
    RE: Condition operator 'NotNull' requires that no values are set. Values.Length: 1

    Am I unclear:)?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans