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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

FetchXML fails in Advanced Find

(0) ShareShare
ReportReport
Posted on by

Hi Team,

I have a FetchXML query that works in an SSRS report but fails in the Advanced Find. (CRM 2016 On Premise) I am using the View Designer within the XRMtoolbox tool. 

I am starting at the Activity and bringing in all Contacts that are equal to an attribute on the contact form. Good so far. I then want to add any opportunity related to those contacts where the parent is the Contact record. I can display the results in the query window just fine. I can run this in an SSRS just fine. It just won't run in the Advanced Find in CRM. 

I am unsure what is wrong unless the View Designer is not saving to CRM correctly?  

Here is what happens when I display columns on the advanced find add columns window. Entire Fetch below. 

1050.opp.PNG

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" count="50" >

<entity name="activitypointer" >
<attribute name="activitytypecode" />
<attribute name="subject" />
<attribute name="statecode" />
<attribute name="prioritycode" />
<attribute name="modifiedon" />
<attribute name="activityid" />
<attribute name="instancetypecode" />
<attribute name="community" />
<attribute name="createdon" />
<attribute name="regardingobjectid" />
<attribute name="ownerid" />
<order attribute="modifiedon" descending="false" />
<link-entity name="contact" from="contactid" to="regardingobjectid" alias="ax" >
<attribute name="address1_postalcode" />
<attribute name="parentcustomerid" />
<attribute name="lastname" />
<attribute name="sl_isvip" />
<attribute name="telephone2" />
<attribute name="fullname" />
<attribute name="firstname" />
<attribute name="sl_issrexecutive" />
<attribute name="emailaddress1" />
<attribute name="address1_city" />
<attribute name="telephone1" />
<filter type="and" >
<condition attribute="new_KeyFieldForContact" operator="not-null" />
</filter>
<link-entity name="opportunity" from="parentcontactid" to="contactid" alias="ai" visible="true" >
<attribute name="campaignid" />
<attribute name="new_verbaltotal" />
<attribute name="sl_opportunitytype" />
<filter type="and" >
<condition attribute="campaignid" operator="not-null" />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Can you please provide layout xml? I believe you have wrong alias used inside. Try to replace that column you have issues with with ai.sl_opportunitytype.

  • Community Member Profile Picture
    on at

    Hi Andrill, my XML is in the post unless what I provided is not what you need?

  • Suggested answer
    ashlega Profile Picture
    34,477 on at

    Hi Maxxsir,

    remove that column and add it again (not from FetchXml, but from the columns - modify that view right in CRM.. btw, that's what Andrii was implying, I believe). It seems you have changed the alias in that fetch along the way, so it's still trying to find that numeric alias, and you have it as "ai" now.

  • Community Member Profile Picture
    on at

    Yes, I tried that but when I put the columns back they don't display the data in the Advanced Find. I am looking for all Activities related to Contacts and Opportunities from 3 different views. I can get the activities and contact columns to display but when I add the opportunity columns they do not display.

    It works in an SSRS report but the Advanced Find does not seem to like they way the XML query is formatted.  

  • Verified answer
    ashlega Profile Picture
    34,477 on at

    Normally, advanced find can only go two levels deep (as far as columns are concerned) - columns from the main and related entities can be displayed, but you can't go beyond that.. maybe that's the problem, since you are trying to display an attribute from the "3d" level..

    Not sure if that would work for you, but you might try to start from the "contacts" and link opportunities/activities to the contacts.

    PS. Either way, the reason you are getting that original error is because there is a different alias/column name now, so it has to be updated this way or another..

  • Suggested answer
    Community Member Profile Picture
    on at

    Alex - Thanks, it is a 3rd level entity issue. I just thought I could sneak by with a FetchXML imported back in to the Advanced Find. I can pull an SSRS report and everything displays as needed.

    That will have to do for my users, just trying to go above and beyond for them with this one..:)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans