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.
The additional steps we would add into the workflow I demonstrated in my other post are the following:
- Initialize a variable to store the approval response as being true or false
- A Until Control that serves as a loop until a condition is met
- 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:
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 last 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:
The last step will stop the while loop from another iteration now that the condition to stop the loop is true.
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:
I hope this helps anyone who may be looking for answers to the above two questions.
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?
Great question, Bao.
The default run duration is 90 days: https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-limits-and-config?tabs=consumption%2Cazure-portal#run-duration-and-history-retention-limits
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.
Post a Comment