Tuesday, August 14, 2012

MSCRM - Dynamically Site Map Based on User Roles

 I want to only show settings Module to the Administrators team. 

1. Create a new entity "new_settings" (Org level)
2. Download Sitemap Editor http://sitemapeditor.codeplex.com/
3. Open Site Map Editor and for each subarea choose "Add Privilege" and specify the entity new_settings.





4. Enable target Roles with the create privilege on the new_settings entity.

Thanks, 
Nicola Grillo

Sunday, August 5, 2012

MSCRM 2011 - Plugin View

In this post I will show steps by steps how to implement plugin on Retrieve Multiple Message using the plug-in registration tool for Microsoft Dynamics CRM 2011

1. Step Create a new plugin

2. Add the following  code snippets.  Fieldname is the field that you want to check (example name of account).

// Comment
protected void ExecuteViewController(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }
            IPluginExecutionContext context = (IPluginExecutionContext)localContext.PluginExecutionContext;
            IOrganizationService service = localContext.OrganizationService;
            QueryExpression qe = (QueryExpression)context.InputParameters["Query"];
            if (qe.Criteria.Conditions != null)
            {
                ConditionExpression queryCondition = new ConditionExpression("fieldname", ConditionOperator.Equal, "value");
                context.InputParameters["Query"] = qe;
            }
        }


3. Add plugin step (example: Account on entity)


4. If you want to add other steps you must repeat third step and you must register the associate event as below.

// Comment
public FilteredViewController()
            : base(typeof(FilteredViewController))
        {
            base.RegisteredEvents.Add(new Tuple>(20, "RetrieveMultiple", "appointment", new Action(ExecuteFilteredViewController)));
            base.RegisteredEvents.Add(new Tuple>(20, "RetrieveMultiple", "account", new Action(ExecuteFilteredViewController)));
            base.RegisteredEvents.Add(new Tuple>(20, "RetrieveMultiple", "lead", new Action(ExecuteFilteredViewController)));
            // Note : you can register for more events here if this plugin is not specific to an individual entity and message combination.
            // You may also need to update your RegisterFile.crmregister plug-in registration file to reflect any change.
        }


Notes:
Previous code snippets (ExecuteViewController) can be used for each entities that contains the target field (fieldname).


Thanks,
Nicola Grillo