I have a plug-in that is attempting to read a custom entity and create a history record in a related entity. However, I am getting no values in my Target entity. Here is the "Execute" code:
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
Entity entity = (Entity)context.InputParameters["Target"];
if (entity.LogicalName != "lena_dlp")
return;
///my code goes past here so I AM getting the proper entity from the form.
IOrganizationServiceFactory serviceFactory =
(IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
try
{
Entity dlphist = new Entity("lena_dlphistory");
///this next line is what causes the Exception.
dlphist["lena_dlp_sn"] = entity["lena_dlp_sn"];
When looking at the "entity" object, the values are non-existent. I can look at entity.Attributes[0] or any other notation and get no results.
What am I missing?
Don DeVeux