Sunday, November 10, 2019

Plugin PreImage and PostImage Part 1


Plugin PreImage and PostImage

Plugins in Dynamics CRM, allow you to register images against the steps of a plugin assembly. Images are a way to pass the image of the record that is currently being worked upon prior or after the action has been performed. In general it could be said, it is the image of the record as is available in the SQL backend.
Two types of Images are supported, Pre-Image and Post Image.
In case of Pre-image, you get the image of the record as is stored in the SQL database before the CRM Platform action has been performed.
Post Image, returns the image of the record after the CRM Platform action has been performed.
As developers, you may have at times, received the following error when trying to implement a plugin.

It is there important to understand when the images would be available and what state of the record would be returned in these images.
Say you were to register a “Pre-Image” for a plugin registered in Pre-Create Stage. We just mentioned above, that the image is a copy of the record as is stored in the SQL backend. Since this is the create stage and the record has not even been created as yet, there is no record in the SQL backend that can be returned in the Pre-Image and hence any call for the image would fail with the above error message.
The following table explains the Pre-Image Availability

No comments:

Post a Comment