This is second part of this series. If you are not familiar with the business case, I highly recommend that you read part 1 where I explain the business case and QuickView creation.
Ok, now that we know the background, let’s look at the task at hand.
We have two entities (Account and Registration Info) with a custom unique ID –DBID. When a registration info record is created, we need to find which Account it belongs to, by looking at the DBID custom field value.
Like in all my flows, I will break this down to 3 stages.
- When a registration info record is created – Trigger
- Find the account that has the same DBID – Get records action
- Update the account > Registration Info lookup with the created registration info record ID.
- Go to flow.microsoft.com
- Create a new automated flow and name it appropriately.
- Select Common data service > “When a record is created” connector
4. Add the environment, entity and scope. In this, I have selected scope as organization since this should work for any record within the organization.
5. Add “List items” action from Common Data service. Configure it as below:
‘crmd_dbid’ is the field name that contains DBID in the account entity.
This connector uses OData query and will return all the accounts with the specific DBID.
6. Now that we have the account, we can go ahead and update the “Registration Info” lookup of that account so that it will be linked to the new record and show up in the quick view.
7. As the final step, let’s add account update. Add “Update record” action as below:
As soon as you put the “Account” from previous step as the record identifier, the whole action will go inside a for-each loop. This is because the flow is expecting multiple records from the “List records” action.
Now, we can update the Registration Info lookup with the actual record ID.
All set! Let’s test this now..
Create a new “Registration Info” record. (Account field is non mandatory)
Now, registration info is populating as expected.
Earlier, we needed custom code to map two entities based on a foreign key in dynamics. However, with power automate. It is now really easy to map a lookup based on another field.
Due to the nature of business, users might not create all account related entity records within the account record. They might create them separately. They may later request you to link the records. This flow can be modified to map any two entities based on a custom field.
Try experimenting and you will find more useful applications of this flow.