Saturday, April 29, 2023

Configuring reminders for "Send approval email" action in Logic Apps

A few of my contacts reached out to me with questions after my previous post:

Using Microsoft Forms and Logic App to create an automated submissions and approval process for Azure AD User Creation

… where I demonstrated a workflow for using Microsoft Forms to generate an approval email and create an Azure AD account. One of the challenges they faced was that the approval emails can potentially be missed by the approver, which would leave the workflow continuously running. The ask was whether there would be a way to send a reminder to the approver after a duration. The features available for the Logic App action Send approval email:


… does not provide a built-in way to resend the approval email or reminder so the workaround is to place a parallel branch to continuously loop for a duration and send a reminder if the approval process has not completed and this post serves to demonstrated how this can be done.

Additional Steps

The additional steps we would add into the workflow I demonstrated in my other post are the following:

  1. Initialize a variable to store the approval response as being true or false
  2. A Until Control that serves as a loop until a condition is met
  3. Set the initialized variable that stores the approval response to true when the approval email has been responded to

The following is the workflow with the additional steps.


Step #1 - Initialize a variable to store the approval response as being true or false

Begin by adding an action to initialize a variable with the following configuration:

Name: ApprovalResponse
Type: Boolean
Value: false

The purpose of this step is to create a variable with the value set as false to determine whether the approval process has completed. Given that this is the start of the workflow and the approval email hasn’t even been created and sent, the value is set to false.


Step #2 – A Until Control that serves as a loop until a condition is met

Add a parallel branch beside the Send approval email action:


Add an Until Control Action:


The Until control will serve to continuously loop until the ApprovalResponse variable is set to true. This variable will continue to be false until the other parallel branch has continued with a step that will set the variable to true.

Configure this parallel branch as follows:

1. Place the ApprovalResponse variable as the condition to check whether it is equal to true


2. Add a Delay action with the desired wait time between reminder email should be sent out


3. Add Condition Control to check whether the ApprovalResponse variable is still false after the delay



4. Send a reminder email out

Here is full branch configuration:


Step #3 – Set the initialized variable that stores the approval response to true when the approval email has been responded to

The next action is to add a Set variable action post Send approval email action to set the ApprovalResponse to true that will stop the parallel branch until loop:


This step will stop the while loop from another iteration now that the condition to stop the loop is true.

Step #4 – Add Terminate Action to stop the loop from continuing to run until the 2hr is up

The last step is to add an action to the end of each successful branch to terminate the job rather than have it continue running until the 2hr loop is up. Forgetting to add this step will display a 2-hour runtime for each trigger of this Logic App, which while would still work, does not provide true runtime duration for troubleshooting.

Proceed to add the Terminate action to each successful branch end:


Additional Question

Using multiple Logic App expressions together

Another question I received was whether it was possible to combine multiple Logic App expressions together. One scenario that could cause this workflow to fail is if the requestor of the form accidentally places a space at the beginning or end of the new user’s first or last name because that would cause the User Principal Name to contain a space and leading to the Azure AD Create user to fail. To do this, simply add the desired expression in front of the existing expression for the string.

In the example below, the trim and toLower function is used together:


The code would look as such:

"userPrincipalName": "@{trim(toLower(body('Get_response_details')?['r9b9abc58c2fb468181b916528b9b97ad']))}.@{trim(toLower(body('Get_response_details')?['r17ea325b22b044c2ba26346a3e98c787']))}"


I hope this helps anyone who may be looking for answers to the above two questions.


Unknown said...

Hi Terence, it is Bao here.
Great to see your new post.
As always it is really detailed and practicable.

Got a question here,
If the approver does not take any actions (approve or reject), will the logic app run forever?

Or is there a timeout setting, then set ApprovalResponse to false -> complete the current run -> Other following actions?


Terence Luk said...

Great question, Bao.

The default run duration is 90 days:

What would be ideal is to place another action to check the duration of the run and terminate after a time as a 90 day runtime is too long for such a workflow to run.

Tenzin Jamtsho- Digital Marketer said...

Thank you for sharing nice content. It was worth going through it, Check Digital marketing training in Gurgaon for your skills and business growth.