Hello Friends,
Welcome back with another post of Power Automate. Sometimes, we have a situation where we have multiple level of approvals. In case, if any approver is out of office or on leave, then the approval process gets halted. Is there any way that we can add an Admin in such scenarios?
The answer is YES with a limitation. If the approver is on leave or Out-Of-Office and he/she had activated Auto Replies then we can achieve our goal. Let's see. I will show here how to find whether approver has activated Auto Replies or not. Based upon that, you can use the feature as per your project requirement. Let's start-
- Navigate to Power Automate portal.
- Click on "My flows".
- Click on "+ New flow" and choose "Instant cloud flow".
- Give the flow a name. I am giving "VerifyOutOfOffice".
- Choose the trigger this flow as "Manually trigger a flow".
- Click on Create.
- Now we have an action called "Get mail tips for a mailbox (V2)". It is very useful action. It will give us the information that whether the approver has set any Auto Replies or not. It takes the emails address as input.
- You may give email id as static value as well as using Dynamic Expression window.
- Save it.
- Now, first we will test when our mailbox automatic replies are turned off. I am using my account to show the Test Results. You can give any user email id.
- Now go back to workflow and click on Test.
- Click on Show raw outputs.
- Here, you will find the body >> value. It is having a property "automaticReplies". Presently, it is coming as blank as we have not set any Automatic Replies.
- Now, change the settings of your mailbox and Turn on the Automatic Replies and save the settings.
- Now again test the flow and click on "Show raw outputs".
- As you can see that "automaticReplies" property is now having further sub properties. Out of these, the "message" property is of our use. If there is a message, then it will start from "<div". This is what we can check and use to add an Admin for approval. Even, if the message is not null and have some length then it would also be sufficient to validate.
- Now, go back to Outlook settings. Set the time period for which replies to be send. If the Start or End is having current date, then message will reflect in output otherwise no. Let's take 2 more examples-
- With current date
- Without current date
- As you can see, if the Automatic Replies is ON and is not set for current date then we will not get the message in response. For all other cases, we are getting message. With this feature, we can identify if we need to add another approver or not. Now, how to validate this message. For this, use the "Condition" action-
- Being the output of "Get mail tips for a mailbox (V2)" action is an array which contain only one object so, we will use index as 0 and then we will check for the property "automaticReplies" and then it's nested property "message". Then check it for NULL.
- Next we will check if the length is greater than 0.
- Now save the flow and test it again. Right now, I had set Automatic Replies as ON without any time frame.
- Now, I am setting Automatic Replies as OFF and again Running the flow.
- With all these examples, we have now the clear picture that if the message is there, it means the user is on leave / out-of-office.
- Now, we can put our logic to add another approver.
- This is how, we can trace the availability of any approver.
- Limitation: However, the Automatic Replies are meant only to use during Leave / Out-of-Office; in case, if any user is using to send a default reply, then even, the user is available, the flow will assume that the user is on leave because the automaticReplies/message will return a valid message.
With this, I am concluding this post.
Happy Coding !!!
Will see you again with some new topics.
Stay Safe !
Stay Healthy !
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.