简体   繁体   中英

CRM 2013 - What to do with FetchXML Query In Javascript

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?

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 :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM