Friday, May 18, 2012

MS CRM 4.0 How to Hide System Views

Posted in [Dynamics CRM], [Technical] By Michael Thompson @ 11/11/2008 1:08 PM

In MSCRM 3.0 to hide system view just took a simple trick to the system.  In MSCRM 4.0 Microsoft removed the work around now not letting you get rid of unused or unwanted system views.  Doing some searches I found 2 different System View Hiding Plugins but I did not Like having to recompile or edit XML outside of CRM to get rid of the View.  So looking over the code on MSDN and Darren's CRM Blog, I decided to Modify Darren's Code not to look at pre built into the code GUIDs.  Instead I changed the Query expression to look at the name column (CRM View name and not bring in views starting with "Hidden".) once the plugin is in Open an Entity and open the unwanted view and open properties to rename and add Hidden to the beginning and then save and publish and it is gone from User's site.  Make sure not to try and hide all views or System Required views as it will throw errors in trying to do so.

 

To use this you will need Visual Studio 2005 or VS 2008.  You will also need the CRM 4.0 SDK for Plugin Registration tool and 2 DDLs (microsoft.crm.sdk.dll and microsoft.crm.sdktypeproxy.dll.  The code create a Class Library using C#.  The DLL from the SDK are needed as added references to the Assembly.

 

Information to Register Plugin:

To install you must have the Microsoft Plugin Registration Tool from The SDK.


Register the assembly

Then register a new step.

 

Meggage:  RetrieveMultiple
Primary Entity: savequery
Eventing Pipline: Pre Stage
Execution Mode: Synchronous
Step Deployment: Server                      You can also add Offline

Triggering Pipeline: Parent Pipeline

 

 

The source 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 HideView

{

      public class CCHideViewsPlugin : IPlugin

      {   

            public void Execute(IPluginExecutionContext context)

            {

            /*Removed GUID Build from here*/

            /*orginal Idea came from http://msdynamicscrm-e.blogspot.com/2008/02/hiding-view-in-crm-40-using-plug-in.html */

                  if (context.InputParameters != null)

                  {

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

                        {

                    /*only apply this action if the query is for 'views' or saved queries*/

                              QueryExpression qe = (QueryExpression)context.InputParameters.Properties[ParameterName.Query];                                       

                              if (qe.EntityName == "savedquery")

                              {

                                    if (qe.Criteria != null)

                                    {

                                          if (qe.Criteria.Conditions != null)

                                          {

 

                                                /*The query is edited to look at views not starting with "Hidden" at the begining of the View Name*/

                                                ConditionExpression queryCondition = new ConditionExpression("name", ConditionOperator.NotLike, "Hidden%");

                                                qe.Criteria.Conditions.Add(queryCondition);

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

                                          }

                                    }

                              }

                        }

                  }

            }

      }

}

Comments

Got something to say? Join the discussion »

leave a reply

 [Quick Submit with Ctrl+Enter]

Remember my details
Notify me of followup comments via e-mail

C5_Insight

About C5 Insight

We are a Microsoft Gold Certified partner focusing on SharePoint, Microsoft Dynamics CRM and Salesforce.com.  Learn more about us by visiting our website.

Search

We Wrote the Bible on Microsoft SharePoint and Dynamics CRMBook-Microsoft Dynamics CRM 2011 and SharePoint 2010 Bible

Tags

Maximize

Recent Comments

Maximize

Blog Roll

Maximize

Disclaimer

The information herein may be used solely at your own risk.  No warranty is made by the author or by C5 Insight, Inc.

The opinons expressed herein are those of the individual authors and do not necessarily represent C5 Insight, Inc in any way.

Copyright 2011 by C5 Insight