Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to create a quick search in CRM that spans multiple entities with grouped conditions

Posted on by 145

We are a housing association with a large CRM system (2016 & SP1). We have a new requirement that requires our users to be able to search for people who are current (ie not previous) occupants or residents or who are not residents (eg contractors)

For this purpose, we need to search the Person entity which has a related Tenancy entity. Person has TenancyType field with possible (option set) values Occupant, Resident, Contractor. Tenancy has TenancyStatus field with possible (text) values Current and Previous.

We tried using the following filter criteria in the quick view on the Person entity:

search001.png

thinking that it would return all people who are not previous residents. However we noticed that it would filter out contractors because contractors do not have related tenancy records.

We needed to change the criteria to return all contractors OR all residents and occupants with no previous tenancy. So we changed it to the following:

search002.png

at which point we got stuck because we noticed that it was not possible to AND together the second and the third conditions as the third one is a related entity.

We are wondering what the best way is to achieve the above bearing in mind that we do not want a separate view for each condition, eg one for residents, one for none residents, etc.

Any help or suggestion is greatly appreciated.

*This post is locked for comments

  • Verified answer
    Seemorgh Profile Picture
    Seemorgh 145 on at
    RE: How to create a quick search in CRM that spans multiple entities with grouped conditions

    Thanks to everyone here who spent time answering my question. out of all answers, Ramamathan's was the closest solution to my problem, though I think Tom' would have also solved my problem but I did not test it.

    As Ramamathan suggedted, I changed FetchXml of the query using the FetchXml Editor tool (part of XrmToolbox). However, I did not create a new view and used the original view and saved and published the modified FetchXml back into CRM using Editor tool.

    I had to fiddle around with the FetchXml to get it right, though I also realised that the Quick Find settings in my development organizations were wrong which contributed to my fiddling. At the end, I came up with the following FetchXml:

     <entity name="contact" >

       <attribute name="fullname" />

       <attribute name="maintenancyid" />

       <attribute name="persontype" />

       <order attribute="fullname" descending="false" />

       <filter type="and" >

         <condition attribute="statecode" operator="eq" value="0" />

         <filter type="or" >

           <condition attribute="persontype" operator="eq" value="Contractor" />

    <filter type="and" >

    <condition  attribute="persontype" operator="in"/>

    <value>Tenant</value>

    <value>Occupant</value>

    </condition>

    <condition entityname="tenancy" attribute="tenancystatus" operator="not-like" value="%Previous%" />

    </filter>

         </filter>

       </filter>

       <link-entity name="tenancy" from="tenancyid" to="maintenancyid" visible="false" link-type="outer" alias="a_40ecfe511e26e51180fb005056ad13b7" >

         <attribute name="tenancystatus" />

       </link-entity>

    I hope this will help others facing the same issue like me.

  • Suggested answer
    ram r Profile Picture
    ram r on at
    RE: How to create a quick search in CRM that spans multiple entities with grouped conditions

    1. with the OOB advanced find editor we cannot have an OR condition between two entities. But can be achieved with custom fetchxml.

    2. The first two conditions should be either wrapped into OR  or merged together

    How to overcome this OR condition restriction, Instead of using advanced find editor create a view and modify the fetchxml of that view. To update fetchxml of a view you can use view designer tool in xrm toolbox.

    How to form an OR condition between linked entities, refer below

    exptechsolutions.blogspot.com/.../know-how-or-condition-between-linked.html

  • TomSmelser Profile Picture
    TomSmelser 1,570 on at
    RE: How to create a quick search in CRM that spans multiple entities with grouped conditions

    One suggestion is to add a tenancy counter or flag on people. then add a workflow to update that field in the parent people record when tenancy is added. then when you construct your view you can just look at that field as part of your filter. you will be able to AND. you won't need the tenancy entity.

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: How to create a quick search in CRM that spans multiple entities with grouped conditions

    Hi,

      Is it not working just like that? I am pretty sure it will "and" the conditions if you leave them the way they are on that screenshot

    EDIT: Sorry, had to reread the question. You don't want the first condition to "AND" with the other two, apparently.. not sure there is a solution, then - you have to have those conditions on the same "level" to use "OR", so you'll probably need to re-arrange/duplicate the fields

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans