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 :
Microsoft Dynamics CRM (Archived)

Pre Image for delete message

(0) ShareShare
ReportReport
Posted on by 75

Messages : Delete

Event Pipeline Stage of Execution : Pre-Validation

Pre Image pre image under step

public class DeletePlugin: IPlugin
	{
		
        public void Execute(IServiceProvider serviceProvider)
		{
            //Extract the tracing service for use in debugging sandboxed plug-ins.
            ITracingService tracingService =
                (ITracingService)serviceProvider.GetService(typeof(ITracingService));

           
            IPluginExecutionContext context = (IPluginExecutionContext)
                serviceProvider.GetService(typeof(IPluginExecutionContext));

            // The InputParameters collection contains all the data passed in the message request.
            if (context.InputParameters.Contains("Target") &&
                context.InputParameters["Target"] is Entity)
            {				

                
                Entity entity = (Entity)context.InputParameters["Target"];
tracingService.Trace(" exists ");
if (entity.LogicalName != "contact") 
try {
if (context.PreEntityImages != null && context.PreEntityImages.Contains("PreImage")) {
Entity BeforeDeleteEntity = (Entity)context.PreEntityImages["PreImage"];
} }
catch (FaultException<OrganizationServiceFault> ex) {
throw new InvalidPluginExecutionException("An error occurred in the FollowupPlugin plug-in.", ex);
}
catch (Exception ex) {
tracingService.Trace("FollowupPlugin: {0}", ex.ToString()); throw; }
}
else{
tracingService.Trace("not exists ");

}
} }

Result is not exists

I would like to get entity fileds 

*This post is locked for comments

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

    Hello,

    context.InputParameters["Target"] is Entity for delete plugin will always return false

    context.InputParameters["Target"] is EntityReference is the way to go.

    Also you will have to rewrite line

    Entity entity = (Entity)context.InputParameters["Target"];

    to line

    EntityReference entity = (EntityReference)context.InputParameters["Target"];

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 > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans