Skip to content

Instantly share code, notes, and snippets.

@AshV
Created July 22, 2019 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AshV/fb56824e74e95b1f315cde8192a594bb to your computer and use it in GitHub Desktop.
Save AshV/fb56824e74e95b1f315cde8192a594bb to your computer and use it in GitHub Desktop.
using Microsoft.Xrm.Sdk;
using System;
namespace Plugin
{
public class TestPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
var tracing = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
var factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
var service = factory.CreateOrganizationService(context.UserId);
Entity entity = new Entity();
Entity preImage, postImage;
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
entity = (Entity)context.InputParameters["Target"];
if (context.PreEntityImages.Contains("PreImage") && context.PreEntityImages["PreImage"] is Entity)
preImage = context.PreEntityImages["PreImage"];
if (context.PreEntityImages.Contains("PostImage") && context.PreEntityImages["PostImage"] is Entity)
postImage = context.PreEntityImages["PostImage"];
entity["jobtitle"] = "Working";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment