I have been asked in interview
I said in an interview
Pre image is used to check before value and Post image is used to check after value . I have been asked if system is having the value why post image is required ?
Why actually we need post image
*This post is locked for comments
Just to add on " if system is having the value why post image is required " if you do not use post image then you need to do a retrieve to get the system value by doing another call which is not a good practice considering you can get the system value in post image.
Hope this helps.
You have a plugin that execute on "Name" field of account entity but some one updated name and post code then you will not get value of post code in target as your plugin execute for name only. In this case you need post image. Post image will have post code.
Hi,
Current Context will contain the fields that are changed by the user. Use PostImage to retrieve additional fields apart from the context fields(updated).
Example: User updated account name but you need information from the owner field.
Current Context: Name
PostImage: Owner
Please let us know, in case of any further query.
Hi
Plugins allows us to write custom code to implement custom business logic, this could be just validation, or changing data or any type of operation really.
Now, plugin only triggers on Events (Messages), for example update or delete or create or other
If a Plugin triggers lets say on Update of a field, and lets assume in your plugin code you want to check what was the previous value and whats the new value.
You can only get to the previous value in plugin by asking CRM to give you a copy of the record just before the change was made - This is PreImage
You also want to know whats the new value, for this you are getting the Post Image - The post image is copy of the record after the change but it is not yet fully committed to database. if the plugin fails for some reason, any change in the post image will be lost.
In short, Pre and Post images are just copies of data before change and data after the change. And Post image will only become permanent if the plugin execution completed with no error. If there was an exception in plugin execution, the entire transaction will be rolled back.
Hi Sandeep,
Let me explain one scenario here.
Suppose my plugin is on post update of account record (Email address is update and trigger point for the plugin). Now I want to check previous email as well as new email and need to send email to both email Id's.
Pre-Image will give me previous email Id and Post-Image will give me new email Id.
Some my concern is with email id want some information from account which is I'm updating inside coding. Let say I'm updating Contact number inside coding. In this case I need to post image to get rest of the values which is updated in account.
Please refer following blog for more reference:
community.dynamics.com/.../pre-image-and-post-image-in-dynamics-crm
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
54
Victor Onyebuchi
6