Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

FetchXML

Posted on by 1,695

CRM2016 on Premisis

I have amended this post as I have managed to make some progress. 

I'm creating a custom invoice with VS SSRS. I am using fetchXML as a datasource

I have two datasets in this report

Invoice Header 

<fetch>
  <entity name="invoice" enableprefiltering="1" >
    <attribute name="invoiceid" />
    <attribute name="duedate" />
    <attribute name="datedelivered" />
    <attribute name="invoicenumber" />
    <attribute name="new_invoicetype" />
    <link-entity name="account" from="accountid" to="customerid" link-type="outer" alias="account" visible="true" >
      <attribute name="address2_stateorprovince" />
      <attribute name="address2_line2" />
      <attribute name="new_paybydirectdebit" />
      <attribute name="address2_city" />
      <attribute name="address2_line1" />
      <attribute name="new_companyname"  alias = "companyname" />
      <attribute name="address2_postalcode" />
      <attribute name="address2_line3" />
      <attribute name="name" />
      <attribute name="new_pono" />
    </link-entity>
  </entity>
</fetch>

Now here is my problem. How do I only return the records in a second dataset for the selected invoice. I have tried multiple options but I either get every invoice detail line in the entity or none at all 

Invoice Summary

<fetch>
  <entity name="invoicedetail"  >
    <attribute name="manualdiscountamount" />
    <attribute name="invoiceid" />
    <attribute name="productidname" />
    <attribute name="baseamount_base" />
    <attribute name="priceperunit" />
    <attribute name="quantity" />
    <attribute name="extendedamount_base" />
    <attribute name="extendedamount" />
    <attribute name="baseamount" />
    <attribute name="tax" />
    <link-entity name="product" from="productid" to="productid" link-type="inner" alias="Product" >
      <attribute name="price" />
      <attribute name="description" />
    </link-entity>
 </entity>
</fetch>

*This post is locked for comments

  • Suggested answer
    Felippe Profile Picture
    Felippe 796 on at
    RE: FetchXML

    Hi Pete,

    You can store the GUID of the selected Invoice on a SSRS parameter.

    So after that, you need to pass this parameter to the second dataset to filter by "invoiceid"

    as follows

    "<filter type="and">

        <condition attribute="invoiceid" value="@GUID_OF_SELECTED_INVOICE" uitype="invoice" operator="eq"/>

       </filter>"

    <fetch>

     <entity name="invoicedetail"  >

       <attribute name="manualdiscountamount" />

       <attribute name="invoiceid" />

       <attribute name="productidname" />

       <attribute name="baseamount_base" />

       <attribute name="priceperunit" />

       <attribute name="quantity" />

       <attribute name="extendedamount_base" />

       <attribute name="extendedamount" />

       <attribute name="baseamount" />

       <attribute name="tax" />

       <filter type="and">

        <condition attribute="invoiceid" value="@GUID_OF_SELECTED_INVOICE" uitype="invoice" operator="eq"/>

       </filter>

       <link-entity name="product" from="productid" to="productid" link-type="inner" alias="Product" >

         <attribute name="price" />

         <attribute name="description" />

       </link-entity>

    </entity>

    </fetch>

    If this solves, please mark as Verified Answer.

    Best Regards,

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans