Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 71679

Forum Post: Regarding update plugin

$
0
0
I have s very simple plugin registered on pre operation stage at update message having execution mode as Sysnchronous. Ia m getting exception as An error occurred in the plguin. Can anyone help me here to know where I am going wrong. public void Execute(IServiceProvider serviceProvider) { IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); IOrganizationServiceFactory _serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService _orgService = _serviceFactory.CreateOrganizationService(context.UserId); if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity entity = (Entity)context.InputParameters["Target"]; if (entity.LogicalName == "account") { string notes = "test"; try { if (entity.Attributes.Contains("numberofemployees")) { entity.attributes["description"] = notes; } } catch (FaultException ex) { throw new InvalidPluginExecutionException("An error occured in plugin:",ex); } } }

Viewing all articles
Browse latest Browse all 71679

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>