CRM Blog

February 2008 - Posts

Hiding Views in CRM 4.0 Using a Plug-in
by Darren Liu 02.25.08

Comments    1 Comment(s)

There are many new moving parts added to CRM 4.0 and I am learning something new every day from the community, the projects that I am working on and the people around me. What I have learned this week by working with Sean McNellis at Microsoft is to hide Views using a simple CRM 4.0 plug-in.

As many of you may already know that Microsoft took off the capabilities of sharing views which many people used in CRM 3.0 to hide unwanted System Views from the user's view list. There have been many posts in the CRM newsgroup community on how to hide the views.

My colleague, Jeremy Hofmann found a clever way of hiding the views by updating a bit field in SavedQueryBase table against the MSCRM database. Unfortunately manipulating with the MSCRM database is not encouraged and also not supported by Microsoft. So what can we do?

What I have learned is that we can manipulate the SavedQuery entity through a simple plug-in to control what shows up on the user's view drop down list. There are many neat things that you can do through the savedquery class offered by the SDK, you can read about it in the 4.0 SDK.

In this post, I will show you how to hide some Contact System views by writing a simple plug-in. I will intercept the retrieve operation that CRM used for getting the views and then append more condition logics to the its query expression.

Before:

C# Code:

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.Crm.Sdk;

using Microsoft.Crm.Sdk.Metadata;

using Microsoft.Crm.Sdk.Query;

using Microsoft.Crm.SdkTypeProxy;

using Microsoft.Crm.SdkTypeProxy.Metadata;

namespace CrmAddon.Crm.Plugin {

public class HideContactViewsPlugin : IPlugin

{

     public void Execute(IPluginExecutionContext context)

     {

     // Query the SavedQueryBase table to retrieve the Query Id

    Guid[] Views = new Guid[]

    {

          new Guid("9818766E-7172-4D59-9279-013835C3DECD"), //NA-Contacts: No Orders in Last 6 Months

          new Guid("9C241A33-CA0B-4E50-AE92-DB780D5B2A12"), //NA-Contacts: Responded to Campaigns in Last 6 Months

    };

    if (context.InputParameters != null && gHiddenViews.Length > 0)

    {

        if (context.InputParameters.Properties.Contains(ParameterName.Query))

        {

           QueryExpression qe = (QueryExpression)context.InputParameters.Properties[ParameterName.Query]; //only apply this action if the query is for 'views' or saved queries

           if (qe.EntityName == "savedquery")

           {

                if (qe.Criteria != null)

                {

                     if (qe.Criteria.Conditions != null)

                     {

                          //Append more condition logic to the default query that's used by CRM. In this case, I filtered on the savedqueryid to exclude the views from the Ids identified above.

                          ConditionExpression queryCondition = new ConditionExpression("savedqueryid", ConditionOperator.NotIn, Views); qe.Criteria.Conditions.Add(queryCondition);

                          context.InputParameters.Properties[ParameterName.Query] = qe;

                    }

                }

             }

          }

       }

    }

  }

}

 

Plug-in Registration: Message: RetrieveMultiple
Primary Entity: savedquery
Stage of Execution: Pre Stage
Execution Mode: Synchronous Sample Registration Snapshot:

...

<Step
    CustomConfiguration = ""
    Description = "Hide Contact View Plug-in"
    FilteringAttributes = ""
    ImpersonatingUserId = ""
    InvocationSource = "0"
    MessageName = "RetrieveMultiple"
    Mode = "0"
    PluginTypeFriendlyName = "Hide Contact Views"
    PluginTypeName = "CrmAddon.Crm.Plugin.HideContactViewsPlugin"
    PrimaryEntityName = "savedquery"
    SecondaryEntityName = ""
    Stage = "10"
    SupportedDeployment = "0" >
</Step>

...

After:

As you can see that the "Contacts: No Orders in Last 6 Months" and "Contacts: Responded to Campaigns in Last 6 Months" views are removed from the drop down list. The new CRM 4.0 SDK is really powerful and you can definitely do more with it. E.g. hide/show the view based on the user id or team, etc...

I hope this will help you on your next CRM project. :)

Filed under:
Upgrading to Microsoft Dynamics CRM 4.0 – The Tortoise and the Hare
by Jeremy Cox 02.14.08

Comments    No Comments

As a father of a 2 ½ and 7 month old, I spend A LOT of time reading to my kids. As you’ll recall from the story, the hare was speedy and boasted about being the fastest in the forest. The tortoise finally tired of hearing all of the hare’s boasting challenged the hare to a race, and as the story goes the speedy but overly confident hare lost to the slow and steady tortoise. When I thought about the “life example” this story tells, it only seemed appropriate to use the classic fable as a metaphor for the approach you should consider when upgrading a CRM deployment.

The Hare

Looking at the upgrade as a quick and easy software update (providing new bells and whistles) in more cases than not will work from the perspective of updating software bits. While Microsoft has invested tremendous resources to ensure organizations will have as few issues as possible with the upgrade, at the end of the day this is still software, and no two environments are the same. A quick Google search such as, “Upgrade to Microsoft CRM 4.0 or Upgrading Microsoft CRM” will return a number of articles revealing all those hares who have been fast to perform upgrades. Many of these articles are related to either technical issues or functionality related questions resulting as part of their upgrade process. Hopefully most of them performed the upgrade in a test environment and not their production CRM environment – if you don’t already have a test environment, this is your justification and reason for having one.

However, how does this approach impact your users? Customers? Would new features and functionality available in version 4.0 create greater business value for the organization? Increase productivity of users? Impact the organization’s CRM Investment and ROI as a whole? How will you know if you never talk to the users?

The Tortoise

The tortoise of course sees the upgrade as an opportunity to re-engage with users and to determine how the organization can get more value out of the organization’s CRM investment. Isn’t that what winning this race is really about?

This is the time to sit down as an organization and review the business and technical (software and infrastructure) considerations that may impact your organization’s CRM upgrade. The following questions are examples taken from Crowe’s Microsoft Dynamics CRM 4.0 Upgrade Readiness & Planning document which I believe organizations should be asking as part of the overall upgrade approach:

What are the top challenges our organization has had with the current implementation of Microsoft CRM?

Have users fully adopted the CRM application and corresponding processes? If not, what are the barriers?

Have there been any modifications to the baseline CRM databases and application files?

How will the upgrade impact integration with any external data source(s) or applications?

Does our existing application and database hardware meet software and hardware guidelines and recommendations?

Taking time on the front-end to carefully consider answers to some questions like above should not only help mitigate any risk associated with the upgrade, but provide a CRM implementation more fully aligned with your organization’s business.

Closing Thoughts

Having spent the last 5 years as a CRM consultant (specifically implementing Microsoft CRM), one thing I have learned over time, is that an organization’s CRM deployment never really ends, nor should it. Your users, customers and their needs are constantly evolving, and so your use of technology to support your customer relationship management strategy must also continue to change and evolve. There is no better time than with an application upgrade. So the question is, are you be the hare or the tortoise?