0

I currently need to retrieve a attribute that is present in a Sub-Grid, how I've done this previously is a C# Plugin with a FetchXML Query within to retrieve the attribute.

However, I want to retrieve the attribute and put its context into a field on the CRM Form. Therefore I've constructed the following in a JavaScript Web Resource

function getProduct()
{
var accountID = Xrm.Page.getAttribute("productid");
var AccountIDObj= accountID.getValue();

    if (AccountIDObj!=null)
    {
        AccountID= AccountIDObj[0].id;
            }

var fetch = 

"@<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>
  <entity name = 'quotedetail'>
    <attribute name = 'productid'/>
    <attribute name = 'productdescription'/>
    <attribute name = 'priceperunit'/>
    <attribute name = 'quantity'/>
    <attribute name = 'extendedamount'/>
    <attribute name = 'quotedetailid'/>
  <link-entity name ='product' alias='bf' to='productid' from='productid'>
    <filter type = 'and'>
      <condition attribute='productnumber' value ='" + AccountID + "' operator = 'eq'/>
    </filter>
  <link-entity name='productpricelevel' alias='bg' to='productid' from ='productid'>
    <attribute name = 'amount'/>
   </link-entity>
  </link-entity>
</entity>
</fetch>"

The problem I now have is where to go from here, in C# I'd create a EntityCollection with the query and go from there, does anyone have any suggestions?

Sjharrison
  • 729
  • 3
  • 16
  • 39

1 Answers1

3

To Execute FetchXml queries on client side using Javascript, you can use below libraries

XrmServiceToolKit.js http://xrmservicetoolkit.codeplex.com/wikipage?title=Soap%20Functions

CrmFetchKit.js https://crmfetchkit.codeplex.com/documentation

Happy coding :-)

Thangadurai
  • 2,573
  • 26
  • 32