Hi,
I have table "Test", and I need to calculate the score in another table based on the number of items of "Test" table .
I wrote a plugin that needs to execute when some entries in the test table is deleted and I have registered plugin..But that plugin isn't running, it's not even showing error.
Need help in making this plugin run.
Thanks,
Hey Thanks a lot ... It's working now
So the issue you experience is related to the following lines:
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
when the Delete message is executed - Target is of type of EntityReference and not Entity.
Good luck.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using System.ServiceModel;
namespace Honeywell
{
public class DeletePlugintest : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracingService =
(ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
// Obtain the organization service reference which you will need for
// web service calls.
IOrganizationServiceFactory serviceFactory =
(IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
// IOrganizationService adminservice = serviceFactory.CreateOrganizationService(new Guid(""));
// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity siteYb = (Entity)context.InputParameters["Target"];
try
{
throw new System.Exception("Delete is Working");
}
catch (FaultException<OrganizationServiceFault> ex)
{
throw new InvalidPluginExecutionException("An error occurred in MyPlug-in.", ex);
}
catch (Exception ex)
{
tracingService.Trace("MyPlugin: {0}", ex.ToString());
throw;
}
}
}
}
}
i throwed an error in my plugin which was registered as a step against message on delete , and i didnt get any error confirming my plugin wasnt executed on delete . steps which was registered against create and update are working fine except delete
Hello,
Can you please provide the code of your plugin and a screenshot of a registration step?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156