Copy Dataverse contact phone numbers across different environments based on Contact e-mail address using Power Automate

Sometimes we can easily use manually triggered Power Automate Flows as ‘mini-scripts’, to run actions in bulk, such as creating/modifying data. 

I recently came across the need to sync a field (Business Phone) for contacts with the same email address from different environments, as in the destination environment this field was not previously used/provided, in a situation where we have two separate Power Pages portals and we have the e-mail address in common between the contacts, but the ID of the contacts differ.

By leveraging the actions to handle records from other environments using the ‘From a Selected Environment’ Dataverse actions, we can move or copy data across different environments easily.

In this instance, I had some Power Pages site users on a different environment where the contact ID’s don’t match as the users were registered manually, but they have the email address in common. And we know that the email addresses are unique in both instances due to restrictions imposed.

So we can easily create a flow that is manually triggered and executes the following actions in sequence:

Get Contacts from Source environment : Filter only Contacts that have a Power Pages user assigned

Filter clause:

adx_identity_username ne null 

Get the corresponding contact from the destination environment: Filter portal users with that email from the previous action (add an apply to each action based on the value property of the previous list rows action).

Filter clause:

(adx_identity_username ne null and emailaddress1 eq '@{items('Apply_to_each')?['emailaddress1']}')

Update the desired field (Business Phone) : Use the value from the source environment record.

Notes: This is not the most performant approach but, it’s a really quick way to achieve this data sync (took me a few minutes to create the flow) and get the results. Note that I am not adding complex validations or worrying about exceeding the Flow runs quota as those were only development instances with less than a hundred contacts. For larger instances, you might evaluate a better approach or improve this approach.

References

Connect to other environments using the Dataverse connector – Microsoft Learn

Leave a Reply

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