Create Account hierarchy in Dynamics 365 CE with Flow, based on CoC data

Posted by

We make use of a web services solution and subscription to enrich the accounts with data from the Business register of the Chamber of Commerce (CoC). In this way the records can be filled with validated data from a reliable source, and the accounts get unique numbers so the duplicate detection can intervene when an account with the same number is created. The CoC data contains among others the attributes:
Establishment no., Main branche establishment no. & Main branche (Yes/No).

These attribute values can be used to reconstruct the Account hierarchy of businesses. So based on the establishment number of the main branche I can fetch this record, get its accountid and then fill the lookup field with this Parent Account at the child records. There is no standard way to do this in Dynamics 365 CE, fortunately with Alex Shlega’s Dynamics CRM (TCS Tools) you can use a workflow to set a lookup.
But yes we can just do it with Flow!

Here is the overview of the flow:

So I make use of the Recurrence trigger to get a list of Account records filtered on a country code, not being  a main branche and having a main branche establishment number present.

For each Account record I get the details and get the (one) record where the establishment number is equal to the main branche establishment number of the child record. Then I check if the list is not empty with the expression: @not(empty(body(‘List_Parent_Account_record’)?[‘value’]))

If not, then (for the only one record) I compare the accountid of the main branche account to the (parent) accountid of the child record. At last I update the Parent Account field of the child record with the accountid of the main branche account in case they are not equal.

That’s all.

The next step will be to extend the flow and add the actions to the If No branch: call the webservice to get the CoC data for the missing main branche account, create the account with this data and update the child record with the accountid of the newly created Account record.

To be continued.

Leave a Reply

Your email address will not be published.