Power Automate | Entity Images Between Entities

Sometimes you have related records in Dynamics 365 for Sales in which you would like the parent entity image to display on the child record. For example, you have a Contact record which is a natural entity to hold a profile picture on the form. You have a License related record where you would also like the picture to display. How do you do this? You can create a Power Automate (formerly called Microsoft Flow) to remove the manual process of adding the image to Dynamics 365 two times or more.

Please read this article to get familiar with how images are handled in Dynamics 365.

Create Image Field

This blog is not about instructing how to create an image field on an entity. The below articles will help you with that:

Display Image on Form

The extremely important description that has changed since the above articles were written is that you need to perform these steps in the new UI, via make.powerapps.com.

In my case, I could not get the “Show image in the form” checkbox to be enabled to check with the traditional form development method. In the new UI, everything worked as expected.

Create Power Automate

At a high level, the Power Automate will contain the following steps:

  1. Trigger on edit of the entityimage field on the Contact record
  2. Get Contact record
  3. Check if Contact has an entityimage and desired related record
  4. Get related record
  5. Update related record

Power Automate

To get started with a Power Automate inside a Dynamics 365 solution, follow these steps:

  1. Navigate to make.powerapps.com
  2. Navigate to correct environment
  3. Navigate to Solutions
  4. Navigate to desired Solution
  5. Create new flow
  6. Select Common Data Service (current environment)
  7. Select When a record is created, updated, or deleted

Trigger

Entity-Images

Because Contact is an OOB (Out of the box) field, the logical name for the Entity Image field is entityimage. Add this to Filtering attributes. This will ensure the flow does not trigger for any other reason.

Officially, you can only upload an image for a record that already exists, so it would appear that Create or Update would not be correct. I am leaving it that way in case the record is created programmatically. It can always be changed if needed.

Get Contact Record

Entity-Images

Add a new step and select Create a new record for CDS. Enter the unique identifier from the step that is being created or updated.

Conditions Check

Entity-Images

I added a condition to check if the Contact has a profile picture uploaded. I also added a condition to check if a related record exists as we only want to proceed if it exists.

@outputs(‘Get_Contact’)?[‘body/entityimageid’]

@outputs(‘Get_Contact’)?[‘body/_ebs_license_detail_value’]

*In this case, there is a 1:1 relationship between the Contact entity and the License entity. If you have a 1:N relationship where there are multiple child records, you will need to add a new step to list out the child records and then loop through them and then update the profile picture.

Get Related Record

Entity-Images

In the Yes conditional branch add a new step, select Get a record (Common Data Service), select the correct entity, and enter the related record unique identifier field.

Update Related Record

Entity-Images

Add a new step, select Update a record (Common Data Service), select the correct entity, enter the unique identifier field from the Get a record step above, and enter the image field.

@{outputs(‘Get_Contact’)?[‘body/entityimage’]}

Save your flow and ensure that it is turned on.

Test Power Automate

Test 1

First, I will add a profile picture to the Contact record.

Before Change

Entity-Images

Flow has run successfully.

Entity-Images

After Change

Entity-Images

This blog has demonstrated the ability of Power Automate to dynamically change record images. Have fun with Power Automate, and please contact us with any questions.

Which Dynamics Product Is Best for You?

Answer some basic questions about your company and your requirements, and find out what products would fit your business.

Take Our Quiz

Which Dynamics Product Is Best for You?

Take Our Quiz