Hide Views based on User Roles in Dynamics CRM
There are many scenarios where one can need to hide views for user roles. Here is an example code to hide views on Account entity for specific roles. Let us suppose that we need to hide "Inactive Accounts" and "Customers" views for Roles "Accounts Manager" & "CSR Manager". Here you need to write and register a plugin and add a plugin step as pre-operation on Message "RetrieveMultiple" of "savedquery" entity as highlighted below: Plugin code to hide specific views for specific roles: public void Execute(IServiceProvider sp) { IPluginExecutionContext context = (IPluginExecutionContext)sp.GetService(typeof(IPluginExecutionContext)); IOrganizationServiceFactory factory = (IOrganizationServiceFactory)sp.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = factory.CreateOrganizationServi...