1. 獲取FetchXML。由於FetchXML難以撰寫,因此咱們通常都是使用高級查找來生成FetchXML或者經過其餘工具來生成。我這裏在商機界面經過高級查找製做了一個新的視圖,名稱爲 商機查詢, 查詢結果以下所示:html
而後我將下載的Fetch XML放在桌面上,名稱爲 FetchXML.xml,其中的文本以下:sql
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">服務器
<entity name="opportunity">app
<attribute name="name" />工具
<attribute name="customerid" />測試
<attribute name="estimatedvalue" />fetch
<attribute name="opportunityid" />url
<attribute name="estimatedclosedate" />spa
<order attribute="name" descending="false" />設計
<filter type="and">
<condition attribute="statecode" operator="eq" value="0" />
<condition attribute="ownerid" operator="eq-userid" />
</filter>
<link-entity name="account" from="accountid" to="customerid" alias="ac">
<attribute name="numberofemployees" />
<filter type="and">
<condition attribute="accountid" operator="not-null" />
</filter>
</link-entity>
</entity>
</fetch>
2. 新建報表項目。打開SQL Server Business Intelligence Development Studio,點擊 文件 > 新建 > 項目,項目類型選擇 商業智能項目 中的 報表服務器項目,爲該項目命個名字。
4. 添加數據源。在左邊的 報表數據中 選擇 數據源,右擊,選擇 添加數據源,名稱我輸入CRM,嵌入連接的類型我選擇 Microsoft Dynamics CRM Fetch,鏈接字符串的輸入格式是:將組織的url,好比http://crmserver:5555/DefaultOrg 中的倒數第一個斜線換成分號。而後在數據源中的憑據中選擇 使用此用戶名和密碼,而後輸入用戶名和密碼。
5. 添加數據集。右擊上一步驟添加的數據源,選擇 添加數據集 ,在查詢下面的文本框中輸入咱們以前拿到的FetchXML,而後點擊 刷新字段 按鈕,而後點擊 肯定 按鈕關閉該對話框。你會看到數據集中出來了很多字段。
6. 製做報表。打開報表的工具箱,將一個表拖動到設計界面,而後將要顯示的字段,好比name,customerid,estimatedvalueValue,estimatedcloseddateValue,ac_numberofemployeesValue 拉到表的列中,並稍微下設置格式,更改列標題。完成後效果以下圖所示,而後點擊設計旁邊的預覽能夠看到效果。而後點擊所有保存將它保存下來。注意,拉到報表中的列通常要用自動加上Value的那些列。
若是要格式化請參考文章 Personalizing Reports for Microsoft Dynamics CRM Online 。
CRM Reporting Undocumented Feature Uncovered
7. 開啓報表的預篩選功能。右擊報表數據中的參數文件夾,選擇 添加參數,名稱設置爲 CRM_FilteredOpportunity ,(ps:對於CRM中的報表,以CRM_開頭的參數是會自動變成隱藏參數,由於本查詢主要實體是Opportunity,因此命名爲CRM_FilteredOpportunity)選擇參數可見性設置爲 隱藏 。在默認值中指定默認值,指定的默認值爲 <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="opportunity"><all-attributes /></entity></fetch> 。而後點擊肯定關閉這個窗口。
8. 更改Dataset增長一個參數。而後雙擊 DataSet1 ,在參數中增長一個參數,參數名稱設置爲 CRM_FilteredOpportunity ,參數值設置爲[@CRM_FilteredOpportunity] ,而後點擊 查詢 ,修改查詢的文本,主要是對主實體opportunity增長屬性 enableprefiltering="1" prefilterparametername="CRM_FilteredOpportunity" ,如後圖所示。
10. 測試報表。導航到 銷售 > 商機,點擊 運行報表 > 個人商機報表,在彈出的頁面中作合適的選擇後,點擊 運行報表 按鈕,一下子報表就運行出來了。