View merged Lead, Contact or Account details in Dynamics 365
Merge functionality for Leads, Contacts and Accounts in Dynamics 365 and Dataverse has been around for a while, if you open the record which was deactivated in the merge process you can see where it was merged into. But from the ‘Master’ row there is no clear indicator that data has been merged from another row into this one, nor what data was merged. You can check the audit history but not all users have permissions to view this area and it can be notoriously slow to load.
Customer : Can you add a note in the timeline to show when a row has been merged into, and also what data has been updated from the deactivated row?
Me : Apparently - yes!
This post focuses on the merging of two Contacts but could easily be modified to work for Accounts and/or Leads too. Roll on down to the bottom for an ended to end image of the flow steps if you need it along the way.
triggerOutputs()?['body/InputParameters/SubordinateId']
null is equal to triggerOutputs()?['body/InputParameters/UpdateContent']
Reminder to use HTTP with Microsoft Entra ID (preauthorized)
https://@{uriHost(outputs('GetDeactivatedContactValues')?['body/@odata.id'])}/api/data/v9.2/EntityDefinitions(LogicalName='contact')/Attributes?($select=AttributeType,DisplayName,LogicalName)
split(replace(replace(replace(string(triggerOutputs()?['body/InputParameters/UpdateContent']),'"',''), '{',''), '}',''),',')
first(split(items('ForEachLine'), ':'))
coalesce(outputs('GetDeactivatedContactValues')?[concat('body/', outputs('logicalname'), '@OData.Community.Display.V1.FormattedValue')], outputs('GetDeactivatedContactValues')?[concat('body/_', outputs('logicalname'), '_value@OData.Community.Display.V1.FormattedValue')], outputs('GetDeactivatedContactValues')?[concat('body/', outputs('logicalname'))])
item()?['LogicalName'] is equal to outputs('logicalname')
first(body('FilterDisplayNames'))?['DisplayName/UserLocalizedLabel/Label']
@{outputs('DisplayName')}: @{outputs('Value')}<br>
<br> <br> The below values have been taken from the previous record:<br> @{substring(variables('FormattedUpdateContentResponse'), 0, sub(length(variables('FormattedUpdateContentResponse')), 4))}
Add a note to the timeline of the Active Contact
Finally you can but together all the details into a note on the Contact timeline. It’s a bit busy below but you can see how we are using inputs from the trigger and previous flow steps to formulate this one. The owner of the note will be the user that merged the rows. The note will be added to the active contact which was merged into. Add a new action Microsoft Dataverse > Add a new row
Action Name: AddNoteToActiveRow
Table name: Note
Inputs: (below)
Title: Merged with Contact '@{outputs('GetDeactivatedContactValues')?['body/fullname']}' Description: Link to merged contact: <a href="https://@{uriHost(outputs('GetDeactivatedContactValues')?['body/@odata.id'])}/main.aspx?forceUCI=1&pagetype=entityrecord&etn=contact&id=@{triggerOutputs()?['body/InputParameters/SubordinateId']}">@{outputs('GetDeactivatedContactValues')?['body/fullname']}</a> @{outputs('FormatPrevRecordValues')} Owner (Owners): systemusers/@{triggerOutputs()?['body/RunAsSystemUserId']} Regarding (Contacts): contacts/@{triggerOutputs()?['body/InputParameters/Target/Id']}
And they all lived happily merged for ever after
In case you got lost along the way there is an end to end screenshot of the flow created from the steps above.
And if you scrolled all the way to here I hope you are on your way to leave a lovely comment to say hello also!