07.03.2009, 00:05 | #1 |
Участник
|
Microsoft Dynamics CRM Team Blog: Microsoft Dynamics CRM Pre-Filtering Tips
Источник: http://blogs.msdn.com/crm/archive/20...ring-tips.aspx
============== CRM Pre-Filtering is a very useful option that can be enabled on CRM reports to make them context sensitive and to allow the report to be filtered using the Advanced Find functionality. Although this is a great feature, it is often an area that is not fully understood which can lead to someone encountering unexpected results. How is it Enabled? Automatic Prefiltering (CRMAF_) There are 2 ways to enable the CRM Pre-Filtering functionality. The easiest option is the CRMAF_ method which simply requires aliasing the filtered views with a name that starts with “CRMAF_”. A query such as “Select name from FilteredAccount” can simply be changed to “Select name from FilteredAccount as CRMAF_Account”. Aliasing the Filtered View with a prefix of CRMAF_ will allow CRM to recognize that you would like to enable this entity for pre-filtering. When you enable the CRM Pre-filtering functionality using the CRMAF_ method, CRM will take a query such as the following and modify it when it is uploaded into CRM: SELECT name, accountnumberBecomes: SELECT name, accountnumberThen CRM will pass a query to the P1 parameter depending on how the report is being filtered. For example: If you are running the report from the Reports area and use the Pre-filtering functionality to filter to only show Accounts that are Active, the resulting query would be something like: SELECT name, accountnumberIf you are within a specific Account and run the report, the resulting query would be something like: SELECT name, accountnumberWhen you are looking at a list of Accounts with 3 selected and choose the option to run the report against the selected records, the resulting query would be something like: SELECT name, accountnumberExplicit Filtering The CRMAF_ method works in most cases but for complex queries such as queries using UNION's, you may need to use the 2nd option referred to as Explicit Filtering. The CRM SDK contains information about how to use both methods under the Report Writers Guide section: http://www.microsoft.com/downloads/d...DisplayLang=en Under the Writing Reporting Services Reports section, you can reference the Using Filters in a Report section. Another posting to the CRM Team Blog contained a great explanation of how CRM Pre-Filtering is enabled: Inside Report Prefiltering. A potential problem is that when you use the CRMAF_ method, CRM needs to add the parameter for you as opposed to you creating the parameter yourself when using Explicit Filtering. With a more complex query such as a query using UNION statements, this can lead to unexpected results as CRM may only add the parameter to the first query. For example, suppose you had a query such as the following: SELECT name, accountnumberWhen you upload the report, CRM may just filter the first query using the parameter which would cause the CRM filtering to not be applied to the second query causing unexpected results: SELECT name, accountnumberFor example: In the scenario above, running the report from the Reports area and choosing to filter where Annual Revenue > 1,000,000, the resulting query would be something like: SELECT name, accountnumberThis would mean it would return any Accounts in Florida with a Annual Revenue of $1,000,000 or any Account in California (not just ones over $1,000,000). If you download the report from CRM and open it in Visual Studio, you will see the original version of the report that you uploaded into CRM. If you download the report from SRS directly, you would see that CRM had modified the query but did not place the parameter where you wanted it to exist: SELECT name, accountnumberTo resolve this issue you can use Explicit filtering. This requires you to create the parameter yourself but you are able to place it anywhere in your query you want. You need to use dynamic SQL to do this as shown in the CRM SDK. Instead of a query such as the following: select name, accountnumber from FilteredAccount as CRMAF_AccountIf you are looking for more examples of Explicit Filtering, you can look at any of the standard CRM reports. All of the standard CRM reports use the Explicit Filtering method. Common Issues Related to CRM Pre-Filtering Reports displaying less data than expected Potential Cause 1Reports displaying more data than expected The CRMAF_ method is being used but Explicit Filtering is necessary to correctly enable CRM Pre-Filtering (see Explicit Filtering under the How is it Enabled section under the CRM Pre-Filtering topic). Try the Explicit Filtering option. Thanks, Dana Martens Источник: http://blogs.msdn.com/crm/archive/20...ring-tips.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
|