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

Community site session details

Session Id :
Dynamics 365 Community / Blogs / DynamicsDevPro / {know-how} Or condition bet...

{know-how} Or condition between linked entities or multiple entites in MSCRM Fetchxml

ram r Profile Picture ram r
I have seen many struggling to achieve an OR condition between filters in parent entity and the linked entity. So today lets see how to overcome this issue and how to achieve an OR condition spanning between multiple entities.

Scenario:
I want to select an account with specific phone number or its primary contacts phone number is equal to the given number

Gap:
In this scenario we may not able to form an or condition for the filters as the filters are split between the parent(account) and the linked entity(contact) in advanced find editor. But the same can be achieved in fetchxml.

Solution:
Fetchxml supports conditions from other linked entities, the trick is to use an attribute called entityname in condition node to specify which entity it links to. The same is highlighted below.



<fetch version="1.0" output-format="xml-platform" mapping="logical" >
<entity name=
"account" >
<attribute name=
"accountid" />
<filter type=
"or" >
<condition attribute=
"telephone1" operator="eq" value="1234" />
<condition
entityname="contact" attribute="telephone1" operator="eq" value="1234" />
</filter>
<link-entity name="contact" alias="contact" from="contactid" to="primarycontactid" />
</entity>
</fetch>

Hope this helps!

This was originally posted here.

Comments

*This post is locked for comments