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)

Problem in FetchXML

(0) ShareShare
ReportReport
Posted on by 7,042

Hello Guys,

I have problem in working with FetchXml (Integrating Asp.Net with MS CRM 2013 Online)

I want to retrieve record from Opportunity, I generate the Fetch-Xml using advanced (Xml contains link entities also)

Then in that Xml i added some attributes name for the link entity

When i run the code, it retrieves the data from crm, but the problem is (for Ex: opportunity is having only 4 records)

It shows different attribute count for all 4 records (i used debug to find the attribute) 

Ex: First Record 15 attribute

Second Record 12 attribute

Third Record 18 attribute

Fourth Record 14 attribute

Total attribute included in the FetchXml is 18 attributes and some time it also shows the duplicate records

How to overcome those two problem?  Give me an hint to solve this

*This post is locked for comments

I have the same question (0)
  • ScottDurow Profile Picture
    21 on at

    Hi,

    Could you post your fetchxml so we can take a look. It sounds like you are doing a join and so the records are duplicated as part of the join.

  • Aileen Gusni Profile Picture
    44,524 on at

    Hi Saravana

    Try to run the fetch xml tester then you can try to see the result and edit the source if needed

    xrmtoolbox.codeplex.com

    Thanks

  • Sayhaitokumar Profile Picture
    7,042 on at

    Hello Scott,

    Yes you are right I'm doing some join operation

    Please have a look into my fetchxml

    <fetch version='1.0' output-format='xml - platform' mapping='logical' distinct='true'>

                                                   <entity name = 'opportunity'>

                                                      <attribute name = 'name'/>

                                                      <attribute name = 'uts_billtoaccount'/>

                                                      <attribute name = 'uts_billtoaddress'/>

                                                      <attribute name = 'uts_shiptoaddress'/>

                                                      <attribute name = 'uts_salesperson'/>

      <attribute name = 'uts_initialpaymentpercentage'/>

                                                      <attribute name = 'uts_productionpaymentpercentage'/>

                                                      <attribute name = 'uts_deliverypaymentpercentage'/>

                                                      <attribute name = 'uts_completionpaymentpercentage'/>                                                    

      <attribute name = 'customerid'/>

                                                      <attribute name = 'estimatedvalue'/>

                                                      <attribute name = 'statuscode'/>

                                                      <attribute name = 'opportunityid' />

                                                      <order attribute = 'name' descending = 'false'/>

                                                      <filter type = 'and'>

                                              <condition attribute = 'statecode' operator= 'eq' value = '1'/>

                                              <filter type = 'or'>

                                      <condition attribute = 'modifiedon' operator= 'not-null'/>

                                         <condition attribute = 'modifiedon' operator= 'not-null'/>

                                                            </filter>

                                                         </filter>                                                      

                                                       <link-entity name='uts_opportunitylineitem' from='uts_parentopportunity' to='opportunityid' alias='ah'>

                                                         <attribute name = 'uts_quantity'/>

                                                         <attribute name = 'uts_totalprice'/>

                            <link-entity name='product' to='uts_product' from='productid' alias='ad'>

                                                             <attribute name = 'new_quickbookslineitemcode'/>                                                        

                                                           </link-entity>

                                                       </link-entity>

                                                       </entity>

                                                       </fetch>

  • Suggested answer
    Sayhaitokumar Profile Picture
    7,042 on at

    Hi Aileen,

    In my system XrmToolBox is not working (I'm using windows 10)

  • Verified answer
    Community Member Profile Picture
    on at

    Hi saravan,

    It seems that when you try to retrieve the records, some records doesn't contains value so

    that's reason it doesn't returns that attribute of the record. so you have different no of

    attribute for different record.  Its a default behavior of CRM.

  • Suggested answer
    ScottDurow Profile Picture
    21 on at

    Hi,

    With this join you will get the number of opportunities cross joined wiht the opportunitylineitem entity - so if you have 2 line items for each opportunity you will get 8 rows with the opportunity field duplicated twice. If there are null values, then the attribute will not be output in the xml response.

    Hope this answers your question.

  • Verified answer
    Sayhaitokumar Profile Picture
    7,042 on at

    Hello Pankaj and scott,

    Yes you people are right, just now i debugged and found the reason for the duplication and attribute count

    Scott,

    Is there any way to eliminate this duplication?

  • Suggested answer
    ScottDurow Profile Picture
    21 on at

    Hi - the very nature of cross joins means that you are requesting data from a child record and so the parent data will be duplicates for each child otherwise you wouldn't know which parent the child belongs to. When you render the data you can do some sort of tree/grouping.

    Hope this answers your question.

  • suresh maurya Profile Picture
    630 on at

    You can test FetchXML online http://msxrmtools.com

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