Community Question

What Is the Purpose of PreEntityImage and PostEntityImage in Dynamics 365 CE Plug-in Development?

Share knowledge. Learn from experts. Build together.

Question

Entity images allow Dynamics 365 CE plug-ins to access record data before or after an operation without performing an additional retrieve operation. This question explores the difference between PreEntityImage and PostEntityImage and when each should be used. It also discusses filtering attributes, performance considerations, and common plug-in development scenarios.
43 Views Community Discussion

Answers

PreEntityImage and PostEntityImage provide plug-ins with snapshots of an entity's data at different points during the execution pipeline. They are particularly valuable when a plug-in needs to compare the record's state before and after an operation.

A Pre Image represents the entity state before the operation. It is commonly used when a plug-in needs to determine what a field contained before an update. This avoids unnecessary retrieval of the record from Dataverse simply to obtain its previous value.

A Post Image represents the entity state after the operation, where supported by the pipeline stage. It is useful when the plug-in needs access to the resulting state after the operation has occurred. For example, a plug-in could compare an account's previous credit limit with its new credit limit and trigger appropriate business processing.

An important point is that images are not automatically populated with every attribute. Developers should configure the required image and specify the attributes needed by the plug-in. Selecting only required columns reduces unnecessary data transfer and improves maintainability.

A common pattern is:

Pre Image → Previous state
Target → Incoming changes
Post Image → Resulting state

For an Update message, developers should also remember that the Target entity typically contains only the attributes being changed, not the complete record. This is one reason images are so important.

Your Answer

Connect