Home > MS CRM 4.0 > Removing System Views

Removing System Views

Last week i got an requirement from my client to remove some of the system views for the contact Entity.I have tried using customization where we can see all the views that is shown to each entity and removing unwanted system views.Even though after removing from the customization i can see those system views in the CRM.
Finally i got plugin from codeplex to remove all unwanted system views .Code goes below.
namespace CrmAddon.Crm.Plugin
    public class HideContactViewsPlugin : IPlugin
        public void Execute(IPluginExecutionContext context)
            if (!(context.MessageName == MessageName.RetrieveMultiple &&
                context.PrimaryEntityName == EntityName.savedquery.ToString() &&
            QueryExpression qe = context.InputParameters[ParameterName.Query] as QueryExpression;
            if (qe == null)         // Check it’s a QueryExpression
            // Query the SavedQueryBase table to retrieve the Query Id 
            Guid[] Views = new Guid[]
                                    new Guid("{927E6CD8-B3ED-4C20-A154-B8BD8A86D172}"), //NA – Contacts: No Campaign Activities in Last 3 Months
                                    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 (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);
                    context.InputParameters.Properties[ParameterName.Query] = qe;
Categories: MS CRM 4.0
  1. No comments yet.
  1. No trackbacks yet.

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: