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.
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:
- Trigger on edit of the entityimage field on the Contact record
- Get Contact record
- Check if Contact has an entityimage and desired related record
- Get related record
- Update related record
To get started with a Power Automate inside a Dynamics 365 solution, follow these steps:
- Navigate to make.powerapps.com
- Navigate to correct environment
- Navigate to Solutions
- Navigate to desired Solution
- Create new flow
- Select Common Data Service (current environment)
- Select When a record is created, updated, or deleted
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
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.
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.
*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
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
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.
Save your flow and ensure that it is turned on.
Test Power Automate
First, I will add a profile picture to the Contact record.
Flow has run successfully.
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