Sunday, October 22, 2017

Conditional approval in Microsoft Flow

I’m working on self-service solution in Office 365 where a requirement is that your manager has to approve your request. If however you don’t have a manager, then the approval step should be skipped.

image

Flow has an action for retrieving a users manager, so that part is easy. However, if the user does not have a manager, the Flow action will fail. The solution here is to add a parallel branch below the Get manager action. In one path you set the action to run if the previous action failed, in the other if the previous action was successful, like the image below.

image

You find this setting by clicking the ellipses in the upper right corner of your action.

image

The complete solution becomes a little more complicated, but not too much :)

image

First create a variable to hold approval status. If user don’t have a manager, then assign the variable to true in the failed branch as we auto-approve. In the success branch, add the approval action and then a new assign variable action where you check if the result was Approved or not.

After the two branches add a new condition to check if the approval variable was set. This step has to be configured to run either on success or skip of the two variable actions, as only one of them will run depending if you have a manager or not.

No comments:

Post a Comment