Approval flow with Child flow to check if approver is OOF\OOO.
Requisites are:
- Child and Parent flow can be implemented ONLY if the flows are saved in 'Solutions' and not otherwise.
- First create the Child flow and then the Parent flow so as to include the call to Child flow.
Logic is:
- Parent flow with a trigger\scheduled action as needed.
- Sharepoint Excelsheet data source with the list of approvers (and details) that need to be sent to each approver as part of approval flow. In my case, I have excel sheet with approver name, details to sent in approval email, should_send_email (whether approval flow is to be sent to user or not - if value is 'yes' then send email and if value is 'user is OOF' then skip sending email), status_of_approval, approval_sent_timestamp, count_of_reminders_sent (how many times the approval ask was sent).
- Call the Child flow - to check if the approver is OOF\OOO. Child flow will update the excel sheet (of step # 2) as 'user is OOF' if user is OOF.
- List rows from excel where 'should_send_email' eq 'yes'. If user is marked as OOF then approval flow will not be sent.
- Create approval for users. After sending approval, update the excel sheet marking the incremented reminder count by 1 for auditing.
- Wait for approval. Timeout set as needed (I kept it as PT5M i.e. 5 minutes for testing purpose).
- If Approval is received - then update the excel sheet in step # 2
- If no approval is received within timeout then send email notification to user that approval timeout is expired.
By default, the approval timeout period is 30 days.
Child Flow: Check if User is OOF\OOO (out of Office):
- List the rows from Excel - to get the list of user's email id whose OOF is to be checked
- Apply to each - read each 'email Id' from the excel data obtained
- Get mail tips (with the email Id)- to check if user has Automatic Reply set
- Set variable (Save the value of automatic reply)
- Scope - Action if user has automatic reply set
- Condition - if Automatic Reply is ' ' (blank) then do nothing
- else update the row in excel sheet to 'User is OOF' (or any text so as to not been used in Parent flow)
- additionally, if you need to get a counter etc. then it can be added, if any values need to be returned from child to parent flow then it can be done.
- Respond to a Power App or Flow: Is needed so that MS flow understands this is a Child flow and can be called from Parent Flow
Parent Flow:
- Image - Referencing the Child Flow in Parent flow.
The 5-min day is added since it takes time for Sharepoint and MS flow to be synced with latest data picked up by MS flow from Sharepoint excel.
Parent Flow - 1
- Approval flow in Parent Flow
Parent Flow - 2 (Approval Logic)
Child Flow Logic:
- (1) initialize the variables
- Check_User_OOF_1
- Variable to save the text of 'Out of Office' - This variable value will be updated in excel sheet and referenced in Parent flow to exclude entries in excel which have this OOF text.
Check_User_OOF_2
- Check if User is OOF - Individual connector details are in the next image
- Check_User_OOF_3.1
- Individual connector details - Get if user has the Automatic reply set. This is 'get mail tips' action in 'Office365 Outlook' connector. Input is complete email Id of the user whose OOF is to be checked.
- Check_User_OOF_3.2
- Scope - Take action if user has Automatic Reply set
Check_User_OOF_3.3
- 'Respond to a PowerApp or flow' connector - this makes the Parent flow reference this Child flow
Check_User_OOF_4
- Complete flow of this Child flow would look like this -
Check_User_OOF_Complete Flow