Before discussing their implementation, let’s briefly discuss what Pre Images and Post Images are in terms of the Microsoft Power Platform.

  • Pre-Images: These are entity snapshots before the execution of a platform event (such as Update, Delete, etc.). Pre-images are particularly helpful when the plug-in needs to access the attributes values that haven’t been included in the event’s input parameters.
  • Post-Images: These represent the entity state after the event’s execution. Post-Images are commonly used when you need to inform a user or a system about changes that occurred during a certain operation or event.

Table of Contents

How to Create a Pre Image

Creating a Pre Image involves several straightforward steps:

  1. Navigate to the ‘Settings’ > ‘Customizations’ > ‘Customize the System’.
  2. Expand the entity you want to add the image for.
  3. Click on ‘Plug-In Assemblies’, then ‘Images’.
  4. Click ‘New’ > ‘Pre-Image’.
  5. Enter an ‘Image Name’ and select the ‘Image Type’ as ‘PreImage’.
  6. In ‘Select Attributes’, choose the attributes you want and click ‘Save’.

How to Create a Post Image

Creating a Post Image follows a similar process:

  1. Follow the same steps 1 to 4 as outlined for creating a Pre Image.
  2. Click ‘New’ > ‘Post-Image’.
  3. Enter an ‘Image Name’ and select the ‘Image Type’ as ‘Post Image’.
  4. In ‘Select Attributes’, choose the attributes you want and click ‘Save’.

An important note to consider is that this guide refers to ‘Classic Interface’; therefore, the steps might vary slightly in the ‘Unified Interface’.

Implementing Pre Images and Post Images to Support Plug-In Logic

Now that we understand what Pre Images and Post Images are and how to create them, we can discuss how these can support plug-in logic in a practical context. They allow developers to optimize their applications by reducing I/O operations as only minimal changes in data are transmitted rather than the entire data set.

As an example, we might have a plug-in that is triggered when a ‘Sale’ record is created or updated. This plug-in could be responsible for calculating and storing the total of all line items. We only need to re-calculate when the ‘Price’ or ‘Quantity’ fields are updated, and we can create a pre-image to store those field values. When the plug-in fires, it can compare the updated values with those in the pre-image. If they aren’t different, no action would be taken, thereby conserving unnecessary operations and improving overall performance.

Implementing Pre Images and Post Images as part of your plug-in logic can offer significant benefits, including improving the efficiency of your applications. Using these tools effectively is key to building robust and high-performing applications on the Microsoft Power Platform, a critical skill for anyone preparing for the PL-400 exam.

Practice Test

True or False. Pre-Images and Post-Images data collection is not essential to support Plug-in logic?

  • True
  • False

Answer: False

Explanation: Pre-Images and Post-Images are essential for plug-in logic as they provide snapshot data that is required for comparison and tracking purposes.

True or False. Pre-Images in Microsoft Power Platform are snapshots of an entity before the execution of a plug-in.

  • True
  • False

Answer: True

Explanation: Pre-Images helps to access the attribute values that have been overwritten due to the plug-in execution.

Which of the following options correctly describes when Pre-Images are generally used in the Microsoft Power Platform?

  • a) Before a plug-in operation
  • b) After a plug-in operation
  • c) During a plug-in operation
  • d) All of the above

Answer: a) Before a plug-in operation

Explanation: Pre-Images are typically used before the execution of a plug-in to gather a snapshot of an entity’s state prior to the operation.

True or False. Post-Images in Microsoft Power Platform are the snapshots of an entity just before the start of a plug-in operation.

  • True
  • False

Answer: False

Explanation: Post-images are the snapshots of an entity just after a successful operation. They are used to understand what changes were made during the plug-in operation.

Which feature is used by a plug-in setup to register Pre-Image or Post-Image snapshots in Microsoft Power Platform?

  • a) Image Registration
  • b) PluginContext
  • c) Attribute Mapping
  • d) Entity Mapping

Answer: a) Image Registration

Explanation: Developers can use Image Registration as part of a plug-in setup to register Pre-Image or Post-Image snapshots.

True or False. Implementing Pre-Images and Post-Images will not help in reducing the number of SQL database calls.

  • True
  • False

Answer: False

Explanation: Using Pre-Images or Post-Images helps to retrieve data that is necessary for a plug-in’s operation, thus reducing the necessity for additional SQL database calls.

True or False. Post-Images in Microsoft Power Platform can be used to populate Audit logs.

  • True
  • False

Answer: True

Explanation: Post-Images can be used to push changes to an Audit Log after an entity operation has completed.

The entity ‘Contact’ contains an attribute ‘Email’. During plug-in execution, is it feasible to register Post-Images to capture the value changes of the ‘Email’ attribute?

  • a) Yes
  • b) No

Answer: a) Yes

Explanation: Post-Images can be used to register and capture the value changes of the ‘Email’ attribute post the plug-in execution.

When developing Pre-Images and Post-Images, which entities should be considered for image registration in the Microsoft Power Platform?

  • a) Entities used in plug-in logic
  • b) Entities not used in plug-in logic
  • c) All entities
  • d) None of the entities

Answer: a) Entities used in plug-in logic

Explanation: Only entities that are part of plug-in execution require Pre-Images and Post-Images registration and are considered during development.

True or False. Implementing Pre-Images and Post-Images has no effect on the performance of Microsoft Power Platform’s plug-ins.

  • True
  • False

Answer: False

Explanation: Implementing Pre-Images and Post-Images reduces the number of database calls and, in turn, optimizes plug-in performance.

Interview Questions

What is a “Pre-Image” in the context of a Microsoft Dynamics 365 plug-in?

A Pre-Image is a snapshot of a record’s attribute values before the core platform operation takes place. Developers can use pre-images to compare previous and current attribute values.

What is the purpose of implementing “Post-Images” in a plug-in logic?

Post-Images provide a snapshot of the record’s attribute values after the core platform operation has finished. This allows developers to avoid unnecessary service calls to retrieve the record again within the plug-in.

How does using Pre Images and Post Images benefit plug-in performance?

Using Pre Images and Post Images can improve the performance of plug-ins by reducing the need to make extra service calls to retrieve records, thus saving processing time and resources.

How can you register a Pre-image in the Plugin Registration Tool?

To register a Pre-image in the Plugin Registration Tool, follow these steps: 1. Open the Plugin Registration Tool and connect to your organization. 2. Choose a step where the image should be registered, click on Register New Image, select Pre Image and specify the desired entity attributes to capture in the image.

True or False: Is it possible to have multiple Pre and Post Images for a single entity?

True. You can have multiple Pre and Post Images for a single entity. However, each image should have a unique name.

How does the inclusion of Pre Images and Post Images influence the execution pipeline in Dynamics 365?

Pre Images are loaded into the pipeline before the operation begins, while Post Images are loaded afterwards. With these images in the pipeline, a plug-in can compare the Post Image to parameters or the Pre Image to assess what changes were made.

What steps must be taken to use a Post-Image in a plugin for Dynamics 365?

Similar to a Pre-Image, a Post-Image must be selected in the Plugin Registration Tool. It must be associated with a plugin step and configured to capture the required attributes. Within the plug-in code, the Post-Image can then be accessed from the Target Input Parameter of the plugin’s context.

Can Pre Images be used with Create message for an entity in Dynamics 365?

No, Pre Images cannot be used with the Create message as the record does not exist before the operation, therefore there are no attribute values to capture.

Can you use Post Images with Delete messages for an entity in Dynamics 365?

No, Post Images cannot be used with Delete messages because the record no longer exists after the operation, so there are no attribute values to capture.

In which types of Plug-in steps can Pre-Images be implemented?

Pre-Images can be implemented in Update and Delete plug-in steps.

In which types of Plug-in steps can Post-Images be implemented?

Post-Images can be implemented in Create and Update plug-in steps.

Does implementing Pre Images and Post Images require administrative privileges in Dynamics 365?

Yes. Registering a plug-in step and related images requires administrative privileges in the organization.

How can you access Pre-Image from the plugin’s context?

Pre-Image can be accessed from the plugin’s context using the following code:

Entity preImageEntity = (Entity)pluginExecutionContext.PreEntityImages["PreImageAlias"];

Is it possible to include all attributes of an entity in a Pre or Post Image?

Yes, it's possible, but it's not recommended. Including all entity attributes in a Pre or Post Image can have performance implications and it's recommended to include only the attributes that are needed.

What happens if Pre Images or Post Images are not registered for a particular plug-in step?

If Pre Images or Post Images are not registered, the developer will have to make a Retrieve or RetrieveMultiple request to get the required data, adding further overhead to plug-in execution.

Leave a Reply

Your email address will not be published. Required fields are marked *