CRM Consulting Best Practice, Flow, PowerApps, PowerPack, Uncategorized

Flow: parent-child flows for a reusable logic

If (you know) you are going to repeat some steps of the Flow logic (actions, conditions etc) in multiple Flows for different triggers and entities, think about using a child Flow as a container for a reusable logic. Although you can always clone your Flow via Export-Import, making changes to a single module is much easier than to manually repeat it multiple times in different places. There are more chance to make a mistake and/or to not being able to track what’s changed and where.

In my previous post I created the Flow to combine Tags in a long string to a store it in a custom text field.

2_1

Now I would like to extract the logic on the left-hand side into a separate Flow then call that Flow from the parent.

The solution is to trigger a child Flow on Request from a parent Flow. In the request I will pass the parameters required to perform all necessary steps.

After looking closely to the left side of my Flow, I realised 3 things:

  • I’ve created the action, which is not required, Get record;
  • I could easily move the logic into a child Flow;
  • I have to pass only one parameter to my child Flow from the parent.

I use Export/Import to create a copy of the Flow. Then I move “Initialise Description variable” action inside the child Flow, because it make sense.

Step 1. Trigger on Request

I use a sample payload to generate the schema: {“entitytype”:”account”,”entityid”:”4fd004f7-d3d0-457b-9dcf-ef95da338111″}.

“HTTP POST URL” will be generated on Save of the Flow.

2_2

Step 2. Initialise the Description variable.

2_3

Step 3. Getting PowerHashTag Connections for the Account.

I use the parameter entityid passed from the parent Flow to for the Filter Query.

2_4

Step 4. For each PowerHashTag Connection from Step 3 query PowerHashTag then append its Name to the Description.

2_5

Step 5. Update the Account with the Description.

The entityid parameter passed from the parent Flow is required to update the Account record Tags field.

2_62_7

Whole Flow looks like this:

2_8Going back to the parent Flow… I remove the logic block, it’s not required anymore. I use the HTTP call of the child Flow instead:

2_9

On the left-hand side, I’ve got a HTTP call to the child Flow, where “URI” refers to the Step 1. “HTTP POST URL” and “Body” contains the JSON in the format defined in the child Flow.

2_10

I had no issues. It just works.

In my case I tried to solve the problem but it’s more complex than I expected it to be. I will tell you about its next time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s