CRM 2011 – Offline and Outlook Filters and Templates: Local Data Groups
The way in which CRM controls what users download to their online and offline Outlook clients has been improved with the 2011 version, as you can read here. However, in my opinion some of this functionality is not immediately clear. This article is meant to provide a complement to the MSDN article cited above by explaining these features in more detail.
In the next article we’ll see how the CRM 2011 Views and Filters Toolkit can be used to perform tasks related to Filters and Templates, as well as to access some of the functionality that until now was only available through the CRM API.
In the context of this article there are four terms that, in various combinations, mean different things. Let’s note down few facts about each to act as reference while looking at the functionality. The terms are Outlook, Offline, Filter and Template.
This term refers to synchronization capabilities of the CRM Outlook Client when it’s online. The standard Outlook Client is always online. The Offline Outlook Client is online when the user has pressed the “Go Online” button.
This term refers to synchronization capabilities of the CRM Outlook Client when it’s offline. The standard Outlook Client can never be offline. The Offline Outlook Client is offline when the user has pressed the “Go Offline” button.
A filter is a query that CRM uses to determine what data should be synchronized between the CRM server and the Outlook Client. Filters can be of two types: System Filters and User Filters.
This is a template query that can be instantiated as a User Filter for a particular user.
Synchronising Data: Filters
Outlook vs. Offline
Outlook synchronizes only few entities when online, such as contacts, appointments, tasks etc. If the user has installed the Offline CRM Client, Outlook synchronizes much more data than just contacts and activities when going offline. In theory one could choose to have the whole database available offline, which would give an offline user the ability to access the same set of data as if they were working online.
To decide what to synchronise in both scenarios, i.e. to determine Local Data Groups, CRM relies on filters, which are called Outlook Filters or Offline Filters depending on whether they apply to when Outlook is online or offline respectively. In addition, each filter can be a System or User filter.
System vs. User Filters
System Filters are stored in the SavedQueryBase table and they are valid for all users. User Filters are stored in the UserQueryBase table and they apply only to their owner. Think of this difference as the difference between a System View and a Personal View.
Users are empowered to maintain their User Filters, as described here, but only administrators can maintain System Filters. In addition, administrators can control the deployment of User Filters via the template mechanism discussed later in this article.
To recap, the following table shows all available filter types and their main attributes.
|On / Off||S / U||QueryType||Table||Description|
|Online||System||OutlookFilters (256)||SavedQueryBase||Determines which data to synchronise when online. Applies to all users.|
|Offline||System||OfflineFilters (16)||SavedQueryBase||Determines which data to synchronise when offline. Applies to all users.|
|Online||User||OutlookFilters (256)||UserQueryBase||Determines which data to synchronise when online. Applies to one user only.|
|Offline||User||OfflineFilters (16)||UserQueryBase||Determines which data to synchronise when offline. Applies to one user only.|
A consideration related to the table above is that the QueryType attribute is technically not the same for all filters, since filters can be either savedquery or userquery CRM entities, depending on whether they are System or User Filters respectively.
As explained above, users are empowered to maintain their User Filters, but administrators can control the deployment of User Filters via Filter Templates.
Filter Templates are queries that can be instantiated as User Filters. Templates reside in the SavedQueryBase table (the instantiated User Filters are of course in the UserQueryBase table). Each User Filter record contains a reference back to the filter in the UserQueryId.ParentQueryId attribute.
Like Filters, Templates can be for offline or online synchronisation, as shown in the table below.
|On / Off||QueryType||Table||Description|
|Online||OutlookTemplate (131072)||SavedQueryBase||Instantiates a corresponding User Filter of type OutlookFilters.|
|Offline||OfflineTemplate (8192)||SavedQueryBase||Instantiates a corresponding User Filter of type OfflineFilters.|
A Filter Template can be manually instantiated as a User Filter through a call to the InstantiateFiltersRequest request.
Default Filter Templates
A template can be marked as default by setting its SavedQuery.IsDefault attribute.
Each entity can have only one filter template that is marked as default. If you create a custom entity, and set the IsAvailableOffline property, a default filter template is created automatically.
When new users are added to the system, all templates marked with the IsDefault attribute will cause User Filters to be instantiated to those users automatically.
In addition, all User Filters can be manually reset (which includes re-instantiating all the applicable templates) through the ResetUserFiltersRequest request.
To see how the considerations above translate into reality, get your hands on a CRM 2011 instance and run the following query:
SELECT SavedQueryId, Name, Description, QueryType, IsDefault FROM SavedQuery WHERE QueryType IN (131072, 8192) AND ReturnedTypeCode = 2
If the default configuration has not been modified extensively, the query should return the following results:
|65D2CBA8-EEDA-4419-B03B-D9C2D8272E51||My Contacts||Contacts owned by me||8192||1|
|58DC4BEE-60B7-4A84-987F-800296B71404||My Outlook Contacts||Contacts Syncing to Outlook||131072||1|
You can see that there are two Filter Templates for contacts in the SavedQueryBase table: one for Online and one for Offline filters.
If you look in the UserQueryBase table for a particular user:
SELECT TOP 2 Name, Description, QueryType, ParentQueryId FROM UserQuery WHERE QueryType IN (256, 16) AND ReturnedTypeCode = 2 ORDER BY OwnerIdName
You should get the following results:
|My Outlook Contacts||Contacts Syncing to Outlook||256||58DC4BEE-60B7-4A84-987F-800296B71404|
|My Contacts||Contacts owned by me||16||65D2CBA8-EEDA-4419-B03B-D9C2D8272E51|
Each filter in the table above is an instance of its corresponding template, as confirmed by the fact that the ParentQueryId attribute points back to the template.
Hopefully this article sheds some light into Filters, Templates and how they are related to Local Data Groups.
The next article will show how the CRM 2011 Views and Filters Toolkit can be used to perform complex tasks related to Filters and Templates, as well as to access some of the functionality that until now was only available through the API.
Alberto “Templet” Gemin