RE: Where to find input/output parameters for a Plugin?
Hi,
The input parameter contains the entity instance (in most of the cases). To get the message name, you need to use context.MessageName. Here is the sample plugin with all the required properties:
============
public void Execute(IServiceProvider serviceProvider)
{
if (serviceProvider == null)
throw new ArgumentNullException("serviceProvider");
var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
var serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
var tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
var service = serviceFactory.CreateOrganizationService(context.UserId);
var adminService = serviceFactory.CreateOrganizationService(null);
var messageName = context.MessageName.ToLowerInvariant();
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
Entity targetEntity = (Entity)context.InputParameters["Target"];
// Your plugin logic
}
}
============
Hope this helps.