• Ed G.

Using "Run After" as a Condition in Power Automate / Flow

In the last article, Shopify, MailChimp, and D365 with Power Automate, we walked through creating a webhook in Shopify to trigger a flow that adds new customers to both Dynamics 365 and possibly our MailChimp audience depending on the behavior when signing up.

I quickly bumped into a scenario where a customer would sign up on my eCommerce site but was already in the MailChimp audience. Had I stepped back from the process as I was building it, I probably would have anticipated that, as the whole intent of our marketing efforts in MailChimp is to drive people to the eCommerce site...so naturally, they would already exist in the list. I'll save the process aspects of this for later, and talk about what I added in order to keep the flow from erroring out when it tried to add someone who is already there.

Try. Catch. Finally...For Makers

"Try. Catch. Finally." is a series of steps to help avoid unhandled exceptions/errors by giving your flow (or any process, really) a path when things don't go exactly as planned.

  • Try - Do the thing. This can be a single action, or a series of actions grouped into a scope.

  • Catch - Do this if the "Try" thing errors out. It can also be a single action or series in a scope.

  • Finally - Do this no matter what. This can also be a single action or series in a scope.

To do this in Power Automate, we will take advantage of the "Configure run after" on the Catch action.

This will bring up a menu that lets us adjust when the step runs...Here, you can see that this step will only run if the previous step fails (more on that later). The subsequent "Finally" step will simply have all of the boxes checked so that it runs in all instances.

Using Error Handling as a Condition

Tying back to our original intent: Our "Try" step, in this case, is an HTTP GET call to MailChimp to see if the new customer already exists in our audience. If the user does not exist, this HTTP call will return an error, which will trigger the "Catch" step of adding them. The "Finally" step that happens in either case, is to add the audience member to a segment to tag their origin in this campaign.

There is still an opening for trouble if the CheckExistingUser step errors out for a reason other than the user doesn't exist in the MailChimp list, but I think the response body will return the error code, so I can investigate how to leverage that next. Next iteration, maybe...that's one of the things I love about Power Automate: I can keep going back to make things better as I learn new things.

I hope you had a chance to learn something new and don't be afraid to make mistakes along the way. Get in and make a mess.

If you're just getting started in Microsoft Power Automate and are looking for a quick guided-learning session, find my Micro-Job on Collab365. We can chat about what is getting in the way of your flow, and I can point you in the right direction.

Try. Fail. Learn. Repeat.

443 views0 comments

©2018 by The Flying Polymath.