简体   繁体   English

CRM 2013-使用JavaScript中的FetchXML查询做什么

[英]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. 目前,我需要检索子网格中存在的属性,以前我是如何做到的是在其中带有FetchXML查询的C#插件中检索该属性。

However, I want to retrieve the attribute and put its context into a field on the CRM Form. 但是,我想检索属性并将其上下文放入CRM表单的字段中。 Therefore I've constructed the following in a JavaScript Web Resource 因此,我在JavaScript Web资源中构造了以下内容

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? 我现在遇到的问题是从这里去哪里,在C#中,我将使用查询创建一个EntityCollection并从那里去,有人对它有任何建议吗?

To Execute FetchXml queries on client side using Javascript, you can use below libraries 要使用Javascript在客户端执行FetchXml查询,可以使用以下库

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

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

Happy coding :-) 快乐编码:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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