Retrieve Multiple Plugin

Reblogged on ecellorscrm blog

muralikrishnasabbavarapublog's avatarMurali Sabbavarapu CRM Blog

Scenario:

  1. Users have organization level read access on Competitor entity in CRM.
  2. 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)

ret3

Below is the plugin code to achieve the above mentioned requirement.

public void Execute(IServiceProvider serviceProvider)

{

try

{

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)

return;

WhoAmIRequest whoReq = new WhoAmIRequest();// To know the user who logged in

WhoAmIResponse whoResp = (WhoAmIResponse)service.Execute(whoReq);

Guid userid…

View original post 229 more words


Discover more from ECELLORS CRM Blog

Subscribe to get the latest posts sent to your email.

Unknown's avatar

Author: Pavan Mani Deep Y

Passionate for Power Platform. A technology geek who loves sharing the leanings, quick tips and new features on Dynamics 365 & related tools, technologies. An Azure IOT and Quantum Computing enthusiast...

Leave a comment

Discover more from ECELLORS CRM Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading