Using Filtered Views with CRM 3.0

On September 7, 2006, in Dynamics CRM, Reporting, by Mitch Milam

Some of my customers use Microsoft Excel or Access to pull data from the CRM system in order to produce custom reports, or in one instance, to interface with a third-party bulk-email application.

CRM 3.0 has a set of SQL Database Views, called Filtered Views, that are constructed in such a way that CRM Security roles are maintained and you can retrieve nothing using one of these views that you would not ordinarily see while using the CRM application.

One aspect of using filtered views that you must take into consideration is the fact that all data ( that you have access to ) will be retrieved from the specified Entity.  This means both Inactive and Active records.

If you don't take Inactive records into consideration your result set could be drastically different than what you expected and  you may inadvertently expend resources on inactive customers.

Luckily, CRM provides two data fields that can be used to filter your query:

SQL Column Value
statuscode 1 = Active 

2 = Inactive

statuscodename Active 

or

Inactive

 

 

 

 

 

 

 

 

 

So, here is how you would use the above:

 

--
-- Show only active Accounts
--
select * from FilteredAccount where statuscode = 1
 
--
-- Show only active Contacts
--
select * from FilteredContact where statuscode = 1
 

This code instructs SQL Server to return all rows where the statuscode is equal to 1, which is an Active Account or Contact.

 

4 Responses to Using Filtered Views with CRM 3.0

  1. abdullah says:

    Hi
    What is the difference in Views and Filtered View??

  2. mitch says:

    Filtered Views are accessed directly from SQL. Views, in CRM terminology, are a view of the data from within the CRM user interface.

  3. Maria says:

    Why use statuscode instead of statecode? Is there any difference between the two (i.e. can one show "active" while the other shows "inactive")?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>