Entity images provide snapshots of a row before or after a supported message. A pre-image is useful for comparing old values with the incoming Target, while a post-image can expose the resulting values in supported pipeline stages.
Overview
Configure Dataverse plug-in pre-images and post-images to compare row values without extra Retrieve calls and keep plug-in logic efficient.
Step-by-step implementation
- Identify the message and stage where the image is supported and needed.
- Register a pre-image or post-image with a stable alias and include only the columns used by the plug-in.
- Retrieve the image from the context by its configured alias and handle missing image registration explicitly.
- Compare Target values with pre-image values to determine whether a business-relevant value changed.
- Avoid retrieving the same row again unless the plug-in needs columns not available in the image.
Example
var target = (Entity)context.InputParameters["Target"];
var preImage = context.PreEntityImages["PreImage"];
var oldName = preImage.GetAttributeValue<string>("name");
var newName = target.Contains("name")
? target.GetAttributeValue<string>("name")
: oldName;
if (!string.Equals(oldName, newName, StringComparison.Ordinal))
{
tracing.Trace("Name changed.");
}
Common pitfalls
- Do not register every column in an image when only a few are required.
- Do not assume an image exists if the step registration does not include it.
- Remember Target may contain only changed attributes, not a full row.
Testing checklist
Test image aliases, missing image registration, unchanged values and updates where the Target omits the compared column.
Conclusion
Prefer explicit platform metadata and documented service behaviour over assumptions. Test the integration with realistic data, permissions and failure conditions before relying on it in production.