Reblogged on ecellorscrm blog
- Users have organization level read access on Competitor entity in CRM.
- Competitor and system user entity have N:1 relationship and User lookup (Business Require) available in Competitor entity form
Have a requirement that the User should see “Competitor records” for which the respective user is tagged to and this should be applicable in all CRM areas (like Advanced find, Lockups, Views…)
This can be achieved through Plug in with “RetrieveMultiple” message
Initially when the user logged in the system, he has access to all the Competitor records which are not tagged to him. (advanced find)
Below is the plugin code to achieve the above mentioned requirement.
public void Execute(IServiceProvider serviceProvider)
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
if (context.Depth > 1)
WhoAmIRequest whoReq = new WhoAmIRequest();// To know the user who logged in
WhoAmIResponse whoResp = (WhoAmIResponse)service.Execute(whoReq);
View original post 229 more words