Dynamics crm 2011 CRM 2011获取XML以列出帐户并仅显示最近的活动日期
我试图在crm 2011上用fetchxml创建一个报告,其中显示帐户名列表,并且在同一行中仅显示该帐户最近活动的日期 所以 报告应该是这样的Dynamics crm 2011 CRM 2011获取XML以列出帐户并仅显示最近的活动日期,dynamics-crm-2011,crm,fetchxml,Dynamics Crm 2011,Crm,Fetchxml,我试图在crm 2011上用fetchxml创建一个报告,其中显示帐户名列表,并且在同一行中仅显示该帐户最近活动的日期 所以 报告应该是这样的 Account1, Date of most recent activity for Account 1 Account2, Date of most recent activity for Account 2 Account3, Date of most recent activity for Account 3 我有一个提取查询,它提取正确的数据,
Account1, Date of most recent activity for Account 1
Account2, Date of most recent activity for Account 2
Account3, Date of most recent activity for Account 3
我有一个提取查询,它提取正确的数据,但它为帐户的每个活动提取一行,而不仅仅是最新的活动
看来
Account1, Date of most recent activity for Account 1
Account1, Date of other activity for Account 1
Account2, Date of most recent activity for Account 2
Account2, Date of other activity for Account 2
Account3, Date of most recent activity for Account 3
这是我的提货单
有什么建议吗
谢谢。您想要做的事情需要一个子查询。这是一件非常重要的事情 如果您不使用CRM Online,只需使用SQL而不是FetchXml执行标准SSRS查询 如果您只是尝试使用SDK回调数据,那么可以在客户端执行子查询 为什么Max Aggregate不起作用 如果要获取最大值的列是一个数字,则可以使用聚合,但聚合函数AVG、MIN、max或SUM只能应用于integer、float、money、bigint或decimal类型的属性 如果尝试运行此查询,则会出现以下错误:
var xml=@”
";
EntityCollection fetchResult=service.RetrieveMultiple(新的FetchExpression(xml));
不确定该属性是否适用于datetimes,但如果它适用,则可能有效您可以对日期进行排序并仅返回第一条记录
对帐户进行查询,然后为每个帐户返回一个值&使用类似以下内容:
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="activitypointer">
<attribute name="scheduledstart" />
<order attribute="scheduledstart" descending="true" />
<filter type="and">
<condition attribute="scheduledstart" operator="not-null" />
</filter>
</entity>
</fetch>
然后是:
(DateTime)(((Entity)results.Entities.First()).Attributes["scheduledstart"]);
添加一个条件,即关于字段等于for each循环范围内的account.id在这里有什么用处吗?我不是fetchxml专家,但如果您知道回答它所需的fetch,请这样做(我可能有一天会需要它!)
(DateTime)(((Entity)results.Entities.First()).Attributes["scheduledstart"]);