Custom Workflow Activities: How to access Pre and Post entity images

Dynamics CRM plugins allow in some events to register images which may be pre event or post event images whether they represent a copy of the context entity, before or after the core operation is performed, respectively.

https://msdn.microsoft.com/en-gb/library/gg309673.aspx#bkmk_preandpost

Images are only available for certain events:

http://crmbook.powerobjects.com/extending-crm/plug-in-development-and-workflow-extensions/plug-ins/plug-in-images-pre-vs-post/

Images are registered through the Plugin Registration tool. When registering an image is specified:

  • If is a pre image or post image;
  • Which context entity attributes it contains;
  • The name to get it inside the plugin.

The following image illustrates the registration of a pre image and a post image, for a plugin with a step on the post-operation of the account update, where each image contains only the account Name attribute.

register_images_plugin

The next image shows how to get the registered images inside the plugin.

 

plugin_images

With custom workflows activities there is not the possibility to register images, although the CRM “does it for us”, adding images to the custom workflow activity execution context depending on its stage.

The bellow table outlines all the events and stages where workflows can be executed and which images are available for each stage.

Event Stage

(when the custom workflow activity is executed)

Image available (key )
When record is created Pre-event (*)
Post-event (Sync and Async) PostBusinessEntity
When record:

  • status changes;
  • is assigned;
  • fields change;
Pre-event PreBusinessEntity
Post-event (Sync and Async) PreBusinessEntity

PostBusinessEntity

When record is deleted Pre-event PreBusinessEntity
Post-event (Sync) (*)
Post-event (Async) PreBusinessEntity

(*) (Stage not available to register real-time workflows)

Regarding to images in custom workflow activities:

  • Pre image is accessed through the PreBusinessEntity key;
  • Post image is accessed through the PostBusinessEntity key;
  • Both images contain all the attributes of the context entity.

The next image shows how to get both pre and post images, considering that the custom workflow activity is part of a workflow, running on the update event, asynchronously or synchronously after the entity is updated.

workflow_pre_post_images

Leave a comment