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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin in Delete of Account with PreImage: PreImage is incomplete

(0) ShareShare
ReportReport
Posted on by

I have this issue with a plugin im working on and I'm running out of ideas.

This is a plugin registered on:

Message: Delete

Primary Entity: Account

Secondary Entity: None

Pre-Operation (Already tried it on Post-Operation)

Execution Mode: Synchronous

Basically, I need to read the values of the record using the pre image. The preimage have a certain amount of field, not all the available ones.

I'm using:

Entity recordBefore = (Entity)context.PreEntityImages["preImage"];
  foreach (KeyValuePair<String, Object> attribute in recordBefore.Attributes)
{
/*Read each field and do something*/
tracingService.Trace("Key:{0}, Value:{1}", attribute.Key, attribute.Value);
}

However, the "recordBefore" entity is incomplete. I have selected in my preimage a lot of the "address1_xxx" fields and none of them is coming in the preimage. Its also happening with other fields, custom and not custom ones and all of different data types.

Any idea of why is this happening? If I select all the field in the preImage, I get a lot of field.. but not all of them and def. not the "address1_" ones.

*This post is locked for comments

I have the same question (0)
  • Denisse Luna Profile Picture
    on at
    RE: Plugin in Delete of Account with PreImage: PreImage is incomplete

    Awesome, thanks!

    Names were fine but I change the step to Pre-Validation and it works fine. I normally don't use that stage but it seems like is the only way here. THANKS!  

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Plugin in Delete of Account with PreImage: PreImage is incomplete

    My guess is that you are trying to do some coding logic before the Account gets deleted.

    Make sure that when you created this plugin, you have the following:

    • Pipeline Stage: Pre-Validation
    • Pre Image Alias: preImage
    • Parameters: everything with "address1_xx"
    • Execution Order: 1 (assuming you have no other plugins that handle Account on Delete)

    4722.Capture.PNG

    Also make sure you are including the correct schema names in the parameters and that they are the exact same ones in the form. You could be confusing "new_address1_xx" with "address1_xx".

  • Denisse Luna Profile Picture
    on at
    RE: Plugin in Delete of Account with PreImage: PreImage is incomplete

    Thanks for your input. The other field I was not seeing in the preimage, yep, it didnt have data in the record.

    However, the "address1_xx" ones do have data.

    If I run the plugin in the update I can see those address values in the preImage but if I run the plugin in the delete I can't.

    Its seems to be related only to the "address" fields.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Plugin in Delete of Account with PreImage: PreImage is incomplete

    Hi Denisse, the preimage fields that will appear are determined by the Parameters set in the plugin registration tool (see highlighted):

    7103.Capture.PNG

    The reason why some of the "address1_xxx" fields are not appearing in the "recordBefore" entity that you defined is because that entity might not have data in the field you selected. In plugins, if the entity does not have data in the field you selected, then the entity will not have that field at all.

    You may want to do a check like this:

    if (recordBefore.Contains("your field name") {

    //run your code here

    }

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans