有没有办法在 Dynamics CRM 2011 的在线版本中使用 FetchXML 按区域(区域在帐户中定义)在未来 30-60-90 天内关闭的所有机会列表。
我尝试通过在测试数据库上编写 SQL 来做到这一点,并且可以使用以下 SQL:
select Territory.TerritoryId ,
(select count(OpportunityId) from Opportunity where Opportunity.AccountId = Account.AccountId and Account.TerritoryId = Territory.TerritoryId and EstimatedClosureDate < '12/12/2011') as OppIn30Days,
(select count(OpportunityId) from Opportunity where Opportunity.AccountId = Account.AccountId and Account.TerritoryId = Territory.TerritoryId and EstimatedClosureDate < '12/1/2012') as OppIn60Days,
(select count(OpportunityId) from Opportunity where Opportunity.AccountId = Account.AccountId and Account.TerritoryId = Territory.TerritoryId and EstimatedClosureDate < '12/2/2012') as OppIn90Days
from territory left outer join Account on Territory.TerritoryId = Account.TerritoryId --group by Territory.TerritoryId, Account.TerritoryId, Account.AccountId
-- TODO parameterization of query, etc.
SQL 的结果如下所示。
Columns: TerritoryId|OpportunitiesClosingIn30Days|OpportunitiesClosingIn60Days
Data: US 5 1
Europe 1 4
Asia 4 5
由于不支持外连接,是否可以使用 FetchXML 来执行此操作?
如果我在 Opportunity 中添加一个隐藏的区域字段并编写一些代码以便每次创建机会时都会从相应的帐户复制区域,这会有所帮助吗?