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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 98 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 72

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans