Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to use OR with QueryExpression

Posted on by 645

I'm trying to get records that are filtered according to the same field (activitycategory) but different values, when I add more than one condition on the same value I get zero results, this is my code,is there a way to filter according to multiple fields or should I run a new query for each condition:

QueryExpression query = new QueryExpression("phonecall");
            query.Criteria.AddCondition(new  **ConditionExpression("activitycategory", ConditionOperator.Equal, GetConfigByKey("Marketing")));**
            **//query.Criteria.AddCondition(new ConditionExpression("activitycategory", ConditionOperator.Equal, GetConfigByKey("Fun")));**
            **//query.Criteria.AddCondition(new ConditionExpression("activitycategory", ConditionOperator.Equal, GetConfigByKey("Important")));** 
             query.Criteria.AddCondition(new ConditionExpression("statecode", ConditionOperator.Equal, 0));
            query.ColumnSet = new ColumnSet("statecode");
            LinkEntity transmitLink = new LinkEntity("phonecall", "transmit", "regardingobjectid", "transmitid", JoinOperator.Inner);
            transmitLink .LinkCriteria.AddCondition(new ConditionExpression("transmitstatus", ConditionOperator.Equal, 1));
            transmitLink .EntityAlias = "phonecall";
            query.LinkEntities.Add(transmitLink );
            EntityCollection allPhonecalls  = new EntityCollection();

*This post is locked for comments

  • Verified answer
    sahara Profile Picture
    sahara 645 on at
    RE: How to use OR with QueryExpression

    Found the answer in that link :

    msdn.microsoft.com/.../gg309410.aspx

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans