Recent Posts

Donnerstag, 2. Februar 2012

CRM 2011 – Offline and Outlook Filters and Templates: Local Data Groups

Introduction

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.

Some Terminology

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.

Outlook

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.

Offline

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.

Filter

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.

Template

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.

Filter Types

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. Therefore, the QueryType attribute can be of type SavedQueryQueryType or UserQueryQueryType. The two are not equivalent: you can find the definition of the two types here and here.

Filter Templates

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.

Example

To see how the considerations above translate into reality, get your hands on a CRM 2011 instance and run the following query:
1 SELECT
2 SavedQueryId, Name, Description, QueryType, IsDefault
3 FROM
4 SavedQuery
5 WHERE
6 QueryType IN (131072, 8192) AND ReturnedTypeCode = 2
  If the default configuration has not been modified extensively, the query should return the following results:
SavedQueryId Name Description QueryType IsDefault
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:
1 SELECT TOP 2
2 Name, Description, QueryType, ParentQueryId
3 FROM
4 UserQuery
5 WHERE
6 QueryType IN (256, 16) AND ReturnedTypeCode = 2
7 ORDER BY OwnerIdName
  You should get the following results:
Name Description QueryType ParentQueryId
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.

Conclusions

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. http://msdn.microsoft.com/en-us/library/gg328205.aspx  

Replicate Local Data Group (Offline Client / Outlook)

If you are using offline client application in CRM implementation, you will notice that configuring local data group is a very painful task for all developers. For me, most of our customers are using offline client applications in their daily operations. We have to configure local data group for all laptops based on their user roles and configuration. It took more than one and half hour to finish the whole configuration setup for each laptop.
Last year, one of our customers suggested a console application called MSCRM: Automate Local Data Group Creation. It is very helpful application for us. We need to setup configuration for only one laptop (one user role) and copy it to the rest of users' laptops. Amazingly, it took only a few minutes to finish the whole process. But, there still has some draw backs. It required a few configuration steps to finished very carefully. Here is the list of steps for configuration:
  1. Go to SQL server and delete some records
  2. Create one text file which contains the list of views that you want to copy, and
  3. Run batch program with pre-defined parameters/commands, etc.
In short, it is not possible to ask users to help configuration on themselves. They still need supervision of professionals. One mistake can screw up the whole database and operations.
So, I decided to do re-engineer works based on existing application. I changed existing web service calles to CRM 4.0, take out the first step (SQL delete process) and add user interface to automate the whole process. Thanks to David Jennaway for contributing his knowledge, idea and source code to community.
Below is the screen shot of my "Replicate Local Data Group" application:
You can run this application from any location/computer if you have access to their CRM application.
Caution: Please backup your CRM user database first before running this application. Application will delete all Local Data Groups of destination users to prevent duplication.
System Requirement:
  • .NET Framework 2.0
Access Matrix:
  • The login user who is connecting to CRM must be a member of PrivUserGroup. If you done more thant one installation for CRM, you will fine multiple PrivUserGroup in AD. Please make sure you are using correct one for login user.
  • All replicate users must have CREATE, READ, WRITE and DELETE access to their own records (User) in "Saved View" entity. You can find "Saved View" entity under Core Record tab of your user role.
Download Link:
Reference:



http://www.dynamicsconsulting.de/2012/02/02/crm-2011-offline-and-outlook-filters-and-templates-local-data-groups/

www.biztom.de