Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 general forum

Trying to search simultaneity 2 tables with FetchXML

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello All.

I am trying to search simultaneity 2 tables with FetchXML as you may see below. The issue is that it should be a clause "OR" (if has in one table OR in another), but it react always as an "AND".  

This code doesn't work:

        <filter type="or" >
            <condition attribute="description" alias="ap" operator="like" value="%Dear%" />
            <filter type="or" >
                <condition attribute="description" operator="like" value="%Dear%" />
                <condition attribute="title" operator="like" value="%Dear%" />
            </filter>
        </filter>

This code works:

        <filter type="or" >
            <condition attribute="description" alias="ap" operator="like" value="%Dear%" />
            <filter type="or" >
                <condition attribute="description" operator="like" value="%test%" />
                <condition attribute="title" operator="like" value="%test%" />
            </filter>
        </filter>

I tried to write it in many other ways without success.

E.g:

        <filter type="or" >
                <condition attribute="description" alias="ap" operator="like" value="%Dear%" />
                <condition attribute="description" operator="like" value="%Dear%" />
                <condition attribute="title" operator="like" value="%Dear%" />
            </filter>
        </filter>

or:

<link-entity name="activitypointer" from="regardingobjectid" to="incidentid" alias="ap" >
   <attribute name="description" />
   <filter type="or" >
       <condition attribute="description" alias="ap" operator="like" value="%Dear%" />
   </filter>
</link-entity>
<link-entity name="account" from="accountid" to="customerid" link-type="inner" >
   <attribute name="accountnumber" />
</link-entity>
<filter type="or" >
    <condition attribute="description" operator="like" value="%Dear%" />
    <condition attribute="title" operator="like" value="%Dear%" />
</filter>
 

Please, maybe could someone help me with this issue?

Below do you have the full code.

Thank you in advance.

Best regards,

Dante Dantas

--------------------------------------------------------

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" >
    <entity name="incident" >
        <attribute name="title" />
        <attribute name="ticketnumber" />
        <attribute name="tri_responsibleteam" />
        <attribute name="incidentid" />
        <attribute name="tri_incidentnumber" />
        <attribute name="createdon" />
        <attribute name="contactid" />
        <attribute name="ownerid" />
        <attribute name="tri_environment" />
        <attribute name="statuscode" />
        <attribute name="description" />
        <attribute name="prioritycode" />
        <link-entity name="activitypointer" from="regardingobjectid" to="incidentid" alias="ap" >
            <attribute name="description" />
        </link-entity>
        <link-entity name="account" from="accountid" to="customerid" link-type="inner" >
            <attribute name="accountnumber" />
        </link-entity>
        <filter type="or" >
            <condition attribute="description" alias="ap" operator="like" value="%Dear%" />
            <filter type="or" >
                <condition attribute="description" operator="like" value="%Dear%" />
                <condition attribute="title" operator="like" value="%Dear%" />
            </filter>
        </filter>
        <order attribute="title" descending="false" />
    </entity>
</fetch>


  • Priyesh Profile Picture
    Priyesh 7,396 User Group Leader on at
    RE: Trying to search simultaneity 2 tables with FetchXML

    Oh, Apologies,

    I'm not sure how you can achieve that using PHP as I don't have PHP expertise.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Trying to search simultaneity 2 tables with FetchXML

    Dear Priyesh, thank you for the reply, but it didn't help me.

    I do not understand C#. My system is on PHP. What I would like is "just"  the FetchXML code. An example. I looked at the link that did you send but I didn't understand how to apply it on PHP. 

    But thank you again to invest your time to try to help me.

    Best regards,

    Dante Dantas

  • Priyesh Profile Picture
    Priyesh 7,396 User Group Leader on at
    RE: Trying to search simultaneity 2 tables with FetchXML

    If my answer helped you, kindly mark it as verified.

    Thanks.

  • Suggested answer
    Priyesh Profile Picture
    Priyesh 7,396 User Group Leader on at
    RE: Trying to search simultaneity 2 tables with FetchXML

    Hi Dante,

    Apologies, I was looking for a simpler explanation. I hope this blog post explains better.

    To summarize, Link Entities means a temporary entity created by code to retrieve data using fetchXML that you can use inside a C# plugin. The entities you want to retrieve must be related in some way.

    I hope this blog explains better -

    This is with assumption you are aware of making calls to CRM from a C# plugins and querying data using fetchXML.

    Please refer this - themscrmexpert.wordpress.com/.../how-to-fetch-data-from-multiple-crm-entities

    Hope this helps. If so, kindly mark my answer as verified.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Trying to search simultaneity 2 tables with FetchXML

    Dear Priyesh,
    thank you for your reply.

    Sorry, but I didn't understand how to create a "Link Entities". I am new on that subject.

    What I did is:

    ...
        <link-entity name="activitypointer" from="regardingobjectid" to="incidentid" link-type="outer" alias="ap" >
          <attribute name="description" />
        </link-entity>
        <link-entity name="account" from="accountid" to="customerid" link-type="inner" >
          <attribute name="accountnumber" />
        </link-entity>
        <filter type="or" >
          <condition attribute="description" operator="like" value="%Dear%" />
          <condition attribute="title" operator="like" value="%Dear%" />
          <condition entityname="ap" attribute="description" operator="like" value="%Dear%" />
        </filter>
    ...

    But now this query is running without stop.

    I will be very thankful if do you may help me.

    Best regards,

    Dante Dantas

  • Suggested answer
    Priyesh Profile Picture
    Priyesh 7,396 User Group Leader on at
    RE: Trying to search simultaneity 2 tables with FetchXML

    Hi,

    You'll need to use Link Entities, please refer this post - 

    community.dynamics.com/.../256998

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans