基本上我有一个QueryExpression,它返回超过3000个结果.我只需要使用50到200之间.如果我使用普通的SQL我可以使用SELECT TOP 200 .....有没有办法在CRM中使用QueryExpression或FetchXML?
我有一个Fetch XML查询,它对链接实体的聚合计数不符合预期.基本上我正在返回课程列表,并计算当前为该课程注册的联系人数,但即使没有人注册该课程,我也会得到1个已注册的联系人.如果我注册1个联系人,我得到1个计数.如果我注册了5个联系人,我得到5个计数,所以当没有相关记录时,问题似乎解决了无法得到0的计数.
这是Fetch XML
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false" aggregate="true">
<entity name="new_coursesection">
<attribute name="new_termscheduleid" groupby="true" alias="new_termscheduleid" />
<attribute name="new_termid" groupby="true" alias="new_termid" />
<attribute name="new_sectionname" groupby="true" alias="new_sectionname" />
<attribute name="new_name" groupby="true" alias="new_name" />
<filter type="and">
<condition attribute="new_courseid" operator="eq" value="{some guid}" />
<condition attribute="statecode" operator="eq" value="0" />
</filter>
<link-entity name="new_contactcoursesection" from="new_coursesectionid" to="new_coursesectionid" alias="new_contactcoursesection1" link-type="outer">
<attribute name="new_contactcoursesectionid" aggregate="count" alias="coursecount" />
<filter>
<condition attribute="statecode" operator="eq" value="0"/>
</filter>
<order alias="coursecount" descending="true" />
</link-entity>
</entity>
</fetch>
Run Code Online (Sandbox Code Playgroud)
有没有人遇到这个问题,知道一个解决方法?
我已经避免使用fetchxml,因为我一直不确定在调用crmService.Fetch(fetchXml)之后处理结果数据的最佳方法.在几种情况下,我使用带有LINQ的XDocument从此数据结构中检索数据,例如:
XDocument resultset = XDocument.Parse(_service.Fetch(fetchXml));
if (resultset.Root == null || !resultset.Root.Elements("result").Any())
{
return;
}
foreach (var displayItem in resultset.Root.Elements("result").Select(item => item.Element(displayAttributeName)).Distinct())
{
if (displayItem!= null && displayItem.Value != null)
{
dropDownList.Items.Add(displayItem.Value);
}
}
Run Code Online (Sandbox Code Playgroud)
处理fetchxml结果数据的最佳方法是什么,以便可以轻松使用.诸如将这些记录传递到ASP.NET数据网格之类的应用程序将非常有用.
我正在使用FetchXml来查询CRM 4.0.我们有一个特殊情况需要在CRM entites之间进行复合连接.所述FetchXml模式表示的多个链路实体元件是允许的,并且它也表明,多个过滤器/条件的元素可以被添加到链路的实体.我面临的问题是条件元素的value属性似乎不允许实体/列名称.它期望明确声明的值.
例如,FetchXml允许您指定:
<link-entity name='myentity' from='column1' to='column2'/>
Run Code Online (Sandbox Code Playgroud)
...这与T-SQL相当:
JOIN myentity on column1 = column2
Run Code Online (Sandbox Code Playgroud)
它可以让你指定:
<link-entity name='myentity' from='column1' to='column2'>
<filter type='and'>
<condition attribute='column3' operator='eq' value='myvalue' />
</filter>
</link>
Run Code Online (Sandbox Code Playgroud)
...这是T-SQL的等价物:
JOIN myentity on column1 = column2 AND column3 = 'myvalue'
Run Code Online (Sandbox Code Playgroud)
但是,FetchXml不会出现以下内容:
JOIN myentity on column1 = column2 AND column3 = column4
Run Code Online (Sandbox Code Playgroud)
注意区别.FetchXml提供了连接中的条件,但它似乎提供了复合连接,即跨多个列的连接.
有没有人在网络空间中能够使用CRM 4.0中的FetchXml执行复合连接?谢谢!
更多信息:
我正在寻找一个使用FetchXml来完成此任务的答案 - 而不是SQL或QueryExpression语法.上面的SQL只是为了解释这个概念.
我们发现Linq for CRM 2011非常糟糕 - 它似乎没有在其上执行任何QA.作为如何严重破提供商的指示器是像.凡(X => X =="B")的查询工作,但此.凡(X =>"B" == X)可能不依赖于像前述一些条件加入声明.我实际上不得不重写查询提供程序的一部分,并享受我放在一起的废话更好的运气.
然而,这还不能继续,还有其他问题,我没有为MS工作而付钱,所以我正在寻找其他选择.这两个问题出现在QueryExpression&FetchXml中,如下所示:http://msdn.microsoft.com/en-us/library/gg334607.aspx
任何人都可以给我一个诚实的,现实生活中使用QueryExpression与FetchXml的利弊吗?我想知道他们在性能,开发速度,稳健性和灵活性方面的比较.
此刻我知道如何将 addCustomFilter 与 addPreSearch(以及删除变体)结合使用。在传递 filterXml 时,所有这些都可以完美运行,例如:
<filter type="and">
<condition attribute="name" operator="eq" value="test123" />
</filter>
Run Code Online (Sandbox Code Playgroud)
但我就是不知道如何在 addCustomFilter 中使用链接实体以及它是否真的可能。我尝试了以下方法:
<link-entity name="account" from="accountid" to="parentaccountid">
<filter type="and">
<condition attribute="name" operator="eq" value="test123" />
</filter>
</link-entity>
Run Code Online (Sandbox Code Playgroud)
它仍然是相同的过滤器,但它现在被放置在帐户的父帐户上。使用此 filterXml,我想获取所有将帐户“test123”作为父帐户的帐户。
问题是过滤器在 addCustomFilter 中不起作用,但它在 AdvancedFind 中返回结果。
有没有办法在 addCustomFilter 方法中使用链接实体,如果是这样,我做错了什么?
我有一些性能非常慢的SQL报告,因此我们将它们全部转换为FetchXML,但所有SQL报告都具有可选的所有条件,如下所示:
SELECT
...
FROM ...
WHERE (@operator = 'All' OR Operator = @operator)
AND (@new_gen_comp_name = 'All' OR new_gen_comp_name = @new_gen_comp_name)
...
Run Code Online (Sandbox Code Playgroud)
在参数值中,All如果用户选择此值,则存在一个值,该条件将被忽略,因此它将从该字段获取所有值.
现在我想在FetchXML中执行此操作,我尝试or在它们之间放置两个带过滤器的条件,一个用于值,另一个包含空值,如下所示:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
<entity name="incident">
...
...
<filter type="and">
<filter type="and">
<condition attribute="createdon" operator="on-or-after" value="@StartDate" />
<condition attribute="createdon" operator="on-or-before" value="@EndDate" />
</filter>
<filter type="or">
<condition attribute="new_gen_comp_type" operator="in" value="@new_gen_comp_type" />
<condition attribute="new_gen_comp_type" operator="null" />
</filter>
</filter>
...
...
</entity>
</fetch>
Run Code Online (Sandbox Code Playgroud)
只有当用户选择参数的所有值时,这才能正常工作@new_gen_comp_type,但问题是如果用户只选择特定值,它也会包含空值,这是错误的.
那么,如果用户选择select allSQL中的参数值,有没有办法让这些条件成为可选项?
dynamics-crm reporting-services fetchxml dynamics-crm-2011 dynamics-crm-2013
是否可以在视图中显示嵌套链接实体的字段?
我有3个实体:统计信息,帐户和地址.统计信息具有对帐户的查找,并且帐户具有查找地址.我想在Statistics视图中显示所有这些实体的字段.
我试过这个并收到错误:要使用此保存的视图,您必须删除引用已删除或无法搜索的项目的条件和列.
<savedquery>
<IsCustomizable>1</IsCustomizable>
<CanBeDeleted>1</CanBeDeleted>
<isquickfindquery>0</isquickfindquery>
<isprivate>0</isprivate>
<isdefault>0</isdefault>
<returnedtypecode>10008</returnedtypecode>
<savedqueryid>{df101ac4-2e4d-e311-9377-005056bd0001}</savedqueryid>
<layoutxml>
<grid name="resultset" object="10008" jump="sl_name" select="1" preview="1" icon="1">
<row name="result" id="sl_statisticsid">
<cell name="sl_amount" width="100" />
<cell name="sl_date" width="100" />
<cell name="sl_debtor" width="100" />
<cell name="sl_divisioncode" width="100" />
<cell name="sl_source" width="100" />
<cell name="sl_statstype" width="100" />
<cell name="relatedAccount.wl_towncity" width="100"/>
<cell name="relatedAccount.relatedAddress.wl_city" width="100" />
</row>
</grid>
</layoutxml>
<querytype>0</querytype>
<fetchxml>
<fetch version="1.0" output-format="xml-platform" mapping="logical">
<entity name="sl_statistics">
<order attribute="sl_amount" descending="false" />
<attribute name="sl_statstype" />
<attribute name="sl_source" />
<attribute name="sl_divisioncode" />
<attribute name="sl_debtor" /> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用WEB API /api/data/v8.x执行获取XML.一切都很好,除非我有查询涉及"属性包含数字值的地方".例如,以下用于查找电话号码的fetchXML包含"03":
<fetch mapping="logical">
<entity name="account">
<attribute name="name" />
<attribute name="telephone1" />
<order attribute="name" descending="false" />
<filter type="and">
<condition attribute="telephone1" operator="like" value="%03%" />
</filter>
</entity>
</fetch>Run Code Online (Sandbox Code Playgroud)
当我们在WEB API上通过GET运行它时:
https://CRM_URL/api/data/v8.0/accounts?fetchXml=<fetch%20mapping%3D"logical"><entity%20name%3D"account"><attribute%20name%3D"name"%20%2F><attribute%20name%3D"telephone1"%20%2F><order%20attribute%3D"name"%20descending%3D"false"%20%2F><filter%20type%3D"and"><condition%20attribute%3D"telephone1"%20operator%3D"like"%20value%3D"%2503%25"%20%2F><%2Ffilter><%2Fentity><%2Ffetch>
Run Code Online (Sandbox Code Playgroud)
CRM Web API返回无效的XML错误,如下所示:
{"error":{"code":"","message":"无效的XML.","innererror":{"message":"无效的XML.","type":"System.ServiceModel.FaultException`1 [[Microsoft.Xrm.Sdk.OrganizationServiceFault,Microsoft.Xrm.Sdk,Version = 8.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35]]"}}}
如果过滤器值不以数字开头,或者我删除过滤器值上的'%',则查询运行正常.我的结论是,这与我的过滤器值中的"%+ number"的编码和解码有关.
我的查询有什么问题,还是这个Dynamics CRM Web API错误?任何工作?
dynamics-crm fetchxml dynamics-crm-online dynamics-crm-webapi