Posts

Hide Views based on User Roles in Dynamics CRM

Image
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...

Creating, Registering and Calling Custom Actions

Image
Actions are actually Custom messages defined for an entity. Following action is created for lead entity having input and out parameters. Custom Action Plugin C# code, using input parameter and output parameters. public   class   CustomQualify  :  IPlugin {      public   void  Execute( IServiceProvider  serviceProvider)     {         IPluginExecutionContext  context = ( IPluginExecutionContext )                       serviceProvider.GetService( typeof ( IPluginExecutionContext ));           IOrganizationServiceFactory  serviceFactory = ( IOrganizationServiceFactory )                     ...