Skip to content

CRM 2011 Views and Local Data Groups Example – Part I

September 15, 2011

Now that the first incarnation of the CRM 2011 Views and Filters Toolkit is complete and deployed in Codeplex, let me explain how these tools can be combined to carry out common tasks related to System Views, Personal Views and Local Data Groups. You can find more information about the toolkit by selecting the Views Toolkit Category of this blog.

Note

In the remainder of this article, and in all other articles about usage of the toolkit, the custom workflow activities part of the toolkit have been named as shown in the table below. You can name the activities while registering them, or you can use the shortcut described in the “CRM 2011 – Default Name and GroupName for your Custom Activities” article of this blog to name them automatically.

Activity Group Name Name
DeploySystemView AG Utilities Deploy System View
DeployUserView AG Utilities Deploy User View
ResetUserFilters AG Utilities Reset User Filters
RetrieveView AG Utilities Retrieve View

All activities listed above have extended documentation about their input and output parameters in the Documentation section in Codeplex.

To run the examples described in this series of articles you need to download the toolkit from here and install it using the plugin registration tool.

Duplicate a Personal View into another

There are a couple of ways to share views that users have created for themselves: they can be assigned to someone else, or they can be shared.

Sometimes though it would be nice to be able to copy a personal view from one user to another, so that the destination user can own their own copy independently from the original user. This is especially true for complicated views that a user has refined over time. This can be done through workflow by leveraging the CRM 2011 Views and Filters Toolkit.

My Extended Contacts” View

Let’s imagine that the user John Doe has created a view called “My Extended Contacts”; this view shows all active contacts that John has interacted with (i.e. for whom there are related activities that are also related to John).

See the picture below for the filter conditions:

“My Extended Contacts” View

“My Extended Contacts” View

Bill Green wants a similar personal view but he needs to do some modifications to it, so he would like a duplicate of the view to start with.

Let’s create a workflow based on User, called “Duplicate Personal View”, as shown in the figure below:

“Duplicate Personal View” workflow

“Duplicate Personal View” workflow

The workflow is composed of three steps:

1) Retrieve the view

This step uses the RetrieveView custom activity with the following parameters:

RetrieveView Parameters

RetrieveView Parameters

The activity will search for a personal view named “My Extended Contact View” owned by John Doe.

We could add other conditions (such as Returned Entity = Contact or Query Type = MainApplicationView) but I trust that the two conditions I entered will uniquely identify the view I’m looking for.

2) Check that a view was found

The RetrieveView custom activity has a return parameter called “Count of Views” which tells how many views were found. Before proceeding I should make sure that one view (and one only) was found:

Check return value of RetrieveView

Check return value of RetrieveView

3) Deploy to user

This last step uses the DeployUserView custom activity with the following parameters:

Deploy User View parameters

Deploy User View parameters

I’ve set only three parameters, which are:

  • When Existing: Update – This means that if the destination user already has a personal view named “My Extended Contacts”, the activity will overwrite it. See the documentation in Codeplex for other possible values of this parameter.
  • Personal View Owner: User(User) – The target user is the user which the workflow activity is running against. I could also put here the reference to a particular user.
  • View Definition: View Definition(Retrieve the view) – This is the actual definition of the view, which is set to the output parameter of the RetrieveView activity.

The activity will deploy to “User” the view defined in “View Definition”.

I could override some elements of the view, such as Name or Fetch XML, in which case I could also do without the View Definition Parameter, but using View Definition will make sure that all elements of the original view (including its name) are preserved.

Test

Now select the Bill Green user record and run the Duplicate Personal View workflow on it. You will have a new view, owned by Bill, which is an exact replica of John Doe’s view. Note that you could also run the workflow against multiple users, hence duplicating the original view many times over, once for each user.

Conclusions

This example is showing just the beginning of the potential of this toolkit, which can be used to do more complicated and powerful things around Personal Views, System Views, Filters, Filter Templates and Local Data Groups. More articles to come.

Alberto “Views-R-Us” Gemin

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: