web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Message Delete is not working as expected

(0) ShareShare
ReportReport
Posted on by 35

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,

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Can you please provide the code of your plugin and a screenshot of a registration step?

  • Praajna Profile Picture
    35 on at

    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;
    }
    }
    }

    }
    }

    0523.Screenshot-_2800_26_2900_.png

    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

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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.

  • Suggested answer
    Praajna Profile Picture
    35 on at

    Hey Thanks a lot ... It's working now

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans