1
有沒有辦法在Dynamics CRM 2011的在線版 版本中使用FetchXML獲取按地區劃分的所有機會列表(在帳戶中定義區域),並在接下來的30-60-90天內關閉。四處逛逛FetchXML的外部連接限制
我試圖通過一個測試數據庫編寫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,因爲外部連接不受支持?
如果我在商機中添加了一個隱藏領域字段並編寫了一些代碼,以便每次創建商機時都從相應的帳戶複製該領土,這會有幫助嗎?