Workflow Automation: Requesting Overtime for Multiple Collaborators
Workflow Automation: Requesting Overtime for Multiple Collaborators Workflow automation has become an essential pillar for companies seeking to improve operational efficiency and reduce manual tasks. This approach not only saves time, but also ensures greater accuracy in key processes. One of the scenarios where workflow automation can have a significant impact is in the management of overtime requests. Managing extraordinary work requests can be challenging when done manually, as it involves collecting data, communicating with multiple parties involved and ensuring proper record keeping. This traditional process is not only time consuming, but also subject to errors and lack of traceability. This is where workflow automation comes in, providing an efficient, structured and reliable solution to handle these requests from start to finish. In this article, we will explore how to design and implement an automated flow for requesting, reviewing and approving overtime. This flow uses digital tools to centralize information, automatically notify the parties involved and ensure that all required documentation is securely stored. Discover how workflow automation can transform this process, simplify request management and optimize resources in your company. With a well-designed solution, companies can not only improve decision-making agility, but also significantly reduce manual errors and improve communication between teams. Workflow automation is the key to taking operational efficiency to the next level.
Workflow Automation Creation
Step 1.
Access the Power Automate environment: To begin, log in to the Power Automate environment using your corporate credentials. Once inside, you will be presented with the main screen containing a side navigation menu with options such as “My Flows”, “Create” and “Templates”. From this main view, we will proceed to create a new workflow.
Step 2.
Add the flow trigger: Select the “Create” option in the side menu and choose “Instant Cloud Stream”. This will open a window where you must provide a name for your stream and select the initial trigger “When an HTTP request is received”. This trigger will allow the stream to be activated every time it receives an HTTP request coming from the form we will configure later.
Once the trigger has been added, click on it to access its settings. In the “Who can trigger the flow” field, select “Anyone” so that any valid HTTP request will be accepted by the flow. However, the flow cannot be saved yet, as Power Automate requires at least one additional action before saving is allowed. To fulfill this requirement, add an “Initialize variable” action. Configure the variable with the name mailWorkers, type String and leave the “Value” field empty. Once this is configured, save the flow. This step will automatically generate a unique URL that will be used by the form to send requests to the flow.
Step 3.
Form configuration and link to the flow With the generated URL, go to the page where the form designed for this flow is located: https://formulario-trabajo-extraordinario.vercel.app/config On this page, you will be asked for the “Connection URL”, which is the address generated by the trigger. Paste this URL into the appropriate field and click “Generate”. This will produce two key results:
1. The URL of the form that users will use to submit requests.
2. The JSON schema that defines the format in which the data will be sent from the form to Power Automate.
Copy the complete JSON schema and return it to the flow trigger in Power Automate. Paste it into the “Request Body JSON Schema” field within the trigger settings. Save the flow again to apply the changes.
Step 4.
Initial flow test: Before proceeding, perform a test to verify that the form data is correctly sent to the flow. In Power Automate, select the “Test Flow” option and choose “Manually”. This will allow you to observe in real time how the flow is executed. Open the form URL generated earlier, fill in all the fields with test data and submit it. Then, go back to Power Automate and check the “Outputs” of the flow to confirm that all data has been received correctly.
Step 4.
Obtain details of the response: After the “Initialize variable” action corresponding to mailWorkers, add an “Apply to each” action. Set its input with the workers field, which corresponds to the list of workers received from the form.
Inside this loop, add the append to string variable to concatenate the data of each worker in HTML format inside the variable correoTrabajadores in this way we improve the visualization of the information. It uses the following structure for the visualization in mails and messages of Teams and adds the dynamic actions that the form gives us.
This will generate a clear and structured representation of each worker’s data, which will be used in subsequent notifications.
Step 5.
Send the application to human talent Add the action “Initiate and wait for approval”. Configure the following values:
Approval Type: “Approve/Reject – First to respond”. Ï Assigned to: talentohumano@hogarsaludips.com
Title: Request for approval for extraordinary work
Details: Includes the message with the data collected from the form.
Step 6.
Create variables for emails and mentions We are going to need in certain actions of the flow to send mails and make mentions so from now on we are going to initialize those values to use them later. Add the action “Initialize variable” and configure it with the following values
Name: “Correos” (Post Office)
Type: “Array”.
Value: The list of all the emails to which we are going to make mentions inside square brackets and separated by commas (as shown in the following image).
Then we add another action “Initialize variable” to be able to store the mentions that we will make later in the teams groups.
Now we initialize another variable called jsonWorkers in which we are going to join all the JSON structure of the information of the workers to be able to include it in the adaptive card. We are only going to initialize it, so we define it as a string and leave the value empty to fill it later.
Step 7.
Condition whether the application was approved or rejected. Add a Condition to evaluate the outcome of the approval. Set the condition to check if the “Outcome” value of the previous action is equal to “Approve” (or “Aprobado” if Power Automate is set to Spanish).
If approved: Continue with the steps to notify and store the application.
If rejected: Defines the alternative flow with the corresponding notifications.
Step 8.
Send notification by mail in case of rejection: If the request is rejected, the action “Send an email (V2)” or “Send an Email (V2)” is added. Configure the fields as follows:
To: Dynamically selects the email of the responsible leader, obtained from the answers to the form.
Subject: “Request for extraordinary work rejected”.
Body: Customize the content with the form data and the reason for rejection, as shown:
After sending the notification email, add the “Terminate” action. Set the Status field to Succeeded to terminate the flow without continuing with the subsequent steps.
Step 9.
Configuration for approved applications In the True branch (approved requests), additional approvals will be sent to the corresponding Teams groups (Human Resources and Area Leaders) via Adaptive Cards. Before sending the cards, mentions will be generated for the users included in the mail variable.
1. Obtain tokens for mentions: Create an “Apply to Each” control action and select as input the variable “Posts”.
2. Inside the loop, use the action “Get an mention token for a user”. In the User field, select the dynamic value “Current item” provided by the loop. Inside the same loop, add an “Append to string variable” action. Set the values:
Name: Select the variable “Mentions”.
Value: Dynamically selects the Mention token obtained from the previous action.
Then we add the option append to string variable in the variable name we select mentions and in value we select the mention that the previous action gives us.
Step 10.
Post message with mentions in Teams To send mentions to the corresponding channel, add the “Post a message in a chat or channel” action. Set the Post as field to Flow bot, which will send the message on behalf of the flow. Then, in Post in, select Channel to post directly in a channel of the desired team. In Team, choose the team where you want to send the notification, for example, “Human Talent”. Then, select the channel where the message will be published, such as “Approval Notifications”. In the Message field you choose the variable mentions and the text please review this approval request.
Step 11.
Create and Configure an Adaptive Card To create an adaptive card with detailed request information, go to the Adaptive Cards Designer. Select Microsoft Teams as the host and remove all default content. Start with a base structure in JSON format, defining a title with the text “Overtime Approval Request”. This initial structure will look like this:
{
“type”: “AdaptiveCard“,
“body”: [
{
“type”: “TextBlock“,
“size”: “Medium”,
“weight”: “Bolder”,
“text”: “${title}”
}
],
“$schema”: “<http://adaptivecards.io/schemas/adaptive-card.json>”,
“version”: “1.5”
}
To add additional fields such as “Applicant Leader”, inside the body add ColumnSet elements inside the body. Each of these will display a title and the corresponding value. For example, to display the leader’s name, the field would have this structure:
{
“type”: “ColumnSet“,
“columns”: [
{
“type”: “Column”,
“width”: “auto”,
“items”: [
{
“type”: “TextBlock“,
“text”: “Líder Solicitante:”,
“weight”: “Bolder”,
“wrap”: true
}
]
},
{
“type”: “Column”,
“width”: “stretch”,
“items”: [
{
“type”: “TextBlock“,
“text”: “NOMBRE DEL LIDER SOLICITANTE”,
“wrap”: true
}
]
}
]
}
We add action buttons to approve or reject the request. This is done after the body section, adding an array in the actions property. The buttons will have a data field that will send approval or rejection values, along with the request identifier:
“actions”: [
{
“type”: “Action.Submit“,
“title”: “Aprobar“,
“data”: {
“aprobacion“: “Aprobado“,
“solicitudId“: “”
},
“style”: “positive”
},
{
“type”: “Action.Submit“,
“title”: “Rechazar“,
“data”: {
“aprobacion“: “Rechazado“,
“solicitudId“: “”
},
“style”: “destructive”
}
]
As we can see this will be reflected in the display of the adaptive cards page, in this case we already have a field that is the requesting leader, we need to add all the information of the workers, for this we will create an apply to each in which we will go through the list of all workers, therefore we select the dynamic variable workers.
Inside the apply to each we add the action append to string variable, in the name of the variable we select the variable that we had created that is jsonWorkers inside the value we introduce all the JSON structure that is going to be shown together with the dynamic values that the form throws us. The structure would be the following:
{
“type“:“ColumnSet“,
“columns“:[
{
“type“:“Column“,
“width“:“auto”,
“items“:[
{
“type“:“TextBlock“,
“text“:“Trabajador @{item()?[‘id’]}”,
“weight“:“Bolder“,
“wrap“:true,
“horizontalAlignment“:“Center”
}
]
}
],
“separator“:true,
“horizontalAlignment“:“Center”
},
{
“type“:“ColumnSet“,
“columns“:[
{
“type“:“Column“,
“width“:“auto”,
“items“:[
{
“type“:“TextBlock“,
“text“:“Nombre trabajador: “,
“weight“:“Bolder“,
“wrap“:true
}
]
},
{
“type“:“Column“,
“width“:“stretch“,
“items“:[
{
“type“:“TextBlock“,
“text“:“@{item()?[‘nombre’]}”,
“wrap“:true
}
]
}
]
},
{
“type“:“ColumnSet“,
“columns“:[
{
“type“:“Column“,
“width“:“auto”,
“items“:[
{
“type“:“TextBlock“,
“text“:“Concepto:”,
“weight“:“Bolder“,
“wrap“:true
}
]
},
{
“type“:“Column“,
“width“:“stretch“,
“items“:[
{
“type“:“TextBlock“,
“text“:“@{item()?[‘concepto’]}”,
“wrap“:true
}
]
}
]
},
{
“type“:“ColumnSet“,
“columns“:[
{
“type“:“Column“,
“width“:“auto”,
“items“:[
{
“type“:“TextBlock“,
“text“:“Horario Solicitado: “,
“weight“:“Bolder“,
“wrap“:true
}
]
},
{
“type“:“Column“,
“width“:“stretch“,
“items“:[
{
“type“:“TextBlock“,
“text“:“Desde @{item()?[‘horaInicio’]} hasta @{item()?[‘horaFin’]}”,
“wrap“:true
}
]
}
]
},
You can also modify the design of the texts, titles, position and color to your preference. Finally the JSON code should look like this:
{
“type”: “AdaptiveCard”,
“body”: [
{
“type”: “TextBlock”,
“text”: “Solicitud de Aprobación de Horas Extra”,
“wrap”: true,
“spacing”: “Large”,
“horizontalAlignment”: “Center”,
“style”: “heading”,
“fontType”: “Monospace”,
“size”: “Large”,
“weight”: “Lighter”,
“color”: “Accent”,
“isSubtle”: false
},
{
“type”: “ColumnSet”,
“columns”: [
{
“type”: “Column”,
“width”: “auto”,
“items”: [
{
“type”: “TextBlock”,
“text”: “Líder Solicitante:”,
“weight”: “Bolder”,
“wrap”: true
}
]
},
{
“type”: “Column”,
“width”: “stretch”,
“items”: [
{
“type”: “TextBlock”,
“text”: “”,
“wrap”: true
}
]
}
]
},
///AQUI VA LA VARIABLE DINAMICA jsonTrabajadores
“actions”: [
{
“type”: “Action.Submit”,
“title”: “Aprobar”,
“data”: {
“aprobacion”: “Aprobado”,
“solicitudId”: “”
},
“style”: “positive”
},
{
“type”: “Action.Submit”,
“title”: “Rechazar”,
“data”: {
“aprobacion”: “Rechazado”,
“solicitudId”: “”
},
“style”: “destructive”
}
],
“$schema”: “http://adaptivecards.io/schemas/adaptive-card.json“,
“version”: “1.5”
}
After this, we copy the entire JSON structure and enter our flow in Power Automate. We create an action called “Post an adaptive card and wait for a response”. In the configuration options, we select Flow bot in the Post as field, and choose Channel in the Post in field. In the Message field, we paste the JSON we copied previously.
the Team field, we select the corresponding group, in this case Area Leaders, and in Channel, we select the channel where we want to publish the card, such as “Approval Notifications”. Finally, in the Update message field, we can include a thank you message, for example: “Thank you for your response”. Next, we focus on the column sets within the JSON, which have two main elements: the title of the field (for example, “Applicant Leader”) and the value associated with that field. This value will be assigned using the dynamic variables dropped by the form. To do this, inside the text quotes, we replace the static value with the corresponding variable, such as the name of the requesting leader. We repeat this process for all the other fields we need to display.
After the requesting leader column set, we add the dynamic variable jsonWorkers that would look like this:
Now we go down to the actions section to correctly configure the Approve and Reject buttons. Inside the quotation marks corresponding to the requestId field, we assign the dynamic variable of the Approval ID, which is provided by the Start and wait for approval action. This will allow us to link the response of the buttons directly to the request we are processing.
After this, it is advisable to save the stream to make sure there are no errors. Since we are working with a rather complex JSON structure, it is possible that we have accidentally omitted a comma, bracket or other essential element. These errors can prevent Power Automate from correctly interpreting the code and rendering the Adaptive Card as expected. Saving the flow will allow us to identify and correct any problems before continuing.
Step 12.
Create Parallel Branches for Simultaneous Submissions To ensure that requests are sent at the same time to both groups (Human Resources and Area Leaders), create a parallel branch before the action of publishing the card. In this new branch, replicate the previous actions of sending messages and adaptive cards. Just change the team and channel fields to correspond to the “Area Leaders” group. This will ensure that both teams receive the notifications and can respond simultaneously.
The final result should be as follows:
Actions in case of rejection of the application: We go down to the end of the flow and add a new condition. In this condition we must set up two criteria using AND logic, to ensure that the positive case is executed only if both conditions are true. In the first condition, we select the compose result of the first group and verify that it is equal to “Pass”. For the second condition, we do the same but use the compose from the other group. This will ensure that the request will go to the next step only if both approvals have been granted.
Actions in case of rejection of the application: If any of the conditions are false, we must notify the responsible leader about the non-approval. To do this, we add an action Send an email (V2), in which, in the To field, we select the leader’s email from the form. In the Subject field we write: “Extraordinary work request rejected” and replicate the content of the email shown in the image.
Then, we also notify the area leaders about the rejection. For this, we use the action Post a message in a chat or channel, configuring it as Post as: Flow bot, Team: Area Leaders, and Channel: Approval Notifications. In the message, we write the content indicated in the corresponding image.
Preparation of the SharePoint library and template: Before continuing with the actions for approved requests, we must set up a SharePoint library containing an Excel template. This template will be used to generate the extraordinary work reports. You can download it through this link: TEMPLATE OVERTIME REQUEST.xlsx
The template contains two main tables:
TableBoss, which stores information related to the requesting leader or boss.
WorkerTable, which contains the workers’ data. In addition, we create a folder within this library, as shown in the image, to store copies of the template with all the information completed, along with the PDFs generated later.
Preparation of the SharePoint library and template: On the positive side of the condition, the first thing we do is clean up any existing data in the tables, as there may be residual information from previous requests. First, we add a List rows present in a table action to select the table WorkerTable. We configure the location of the template, the document library and the corresponding Excel file. We repeat this process for the table TableBossTable.
Next, we add a Delete a row action to delete all the rows present in the tables. We set the location of the template, select the table TableBoss, and in Key Column we choose “IMMEDIATE CHIEF”, which is the first field of the table. In Key Value, we assign the dynamic variable that is generated from the List rows present in a table action. When doing so, Power Automate will automatically wrap the action in a loop (For each) to delete all existing data. We repeat this procedure for the table TableTableTrabajadores, selecting as Key Column the field “NAME OF COLLABORATOR”.
Step 18.
Insertion of the data in the tables: With the template clean, we proceed to add the relevant information to the tables. We add the Add a row into a table action, select the file location and choose the table TableBoss. We click on Show advanced parameters to display all the columns of the row and assign the corresponding answers from the form to each field, we repeat the process for the table TableWorkers, adding the necessary rows with the information of the workers, the only different with the boss table is that as we are going to receive several workers Power automate detects it and automatically creates the for each one.
Conversion of Excel to PDF and copying to the approved applications folder: With the Excel completed, we proceed to convert it to PDF. Then we use the Copy file action to copy the template to the approved requests folder. Under Current site address and File to copy, we select the location and file of the original template. In Destination site address and Destination folder, we select the destination folder (approved requests). Finally, set the If another file is already there option to Copy with a new name.
We add the action Get file content using path, selecting the location of the Excel template, and in the advanced options we activate Infer Content Type setting it to Yes
Conversion of Excel to PDF and copying to the approved applications folder: To convert the Excel file to PDF, the Convert XLSX to PDF action of the Plumsail connector is used. In this action, you select the file content provided by the previous action to get Excel file content.
If this is the first time this connector is used, it is necessary to create an account in Plumsail Documents, access the API keys section, and generate a new key with the desired name, configuring it in production or test mode as needed. Once the API is connected, the file will be converted.
Step 21.
Temporary storage of the PDF in OneDrive:
The resulting PDF file is temporarily saved to OneDrive using the Create File action. Here you choose a specific folder, such as “Conversions”, and assign a unique name to the file, combining the Forms response ID and the leader’s name, separated by underscores and with the extension “.pdf” at the end. This temporary file facilitates content management in the following steps.
Step 22.
Retrieving PDF content from OneDrive: Subsequently, the content of the PDF file stored in OneDrive is retrieved using the Get File Content action. To do this, the file ID previously generated by OneDrive is selected and the option to infer the content type is enabled to ensure that the file is treated correctly.
Step 23.
Final storage of the PDF in SharePoint: The PDF file is moved to its final location in SharePoint using the Create File action. In this action, the “Approved Requests” folder is selected, assigning it a structured name similar to the one used in OneDrive (Response ID, RequestDate and “.pdf”). The content of the file comes from the Get Content action in the previous step.
Step 24.
Generation of shared links for Excel and PDF: Once the Excel and PDF are stored in SharePoint, shared links are generated for both using the Create Sharing Link for File or Folder action. A view-only link is set up with limited scope to users in the organization. This process is repeated for the Excel and PDF, using the corresponding file identifiers previously generated.
Notification to the responsible leader To notify the responsible leader, an email is sent using Outlook’s Send an Email (V2) action. This email includes a subject line informing about the approval of the request and in the body details the links generated for the Excel and PDF, allowing the leader to directly access the approved files.
Step 26.
Notification to the area leadership group Finally, a notification is sent to the group of area leaders via the Teams Post Message in a Chat or Channel action. This message, sent by the Flow Bot to the corresponding channel, includes information about the approval of the request along with a link to the PDF file, ensuring that everyone involved has access to the approved documents.
Workflow automation is the key to efficiently manage overtime in teams with multiple collaborators. Implementing an automated process not only optimizes time, but also reduces errors and improves productivity. At Pevaar, we are specialists in developing customized software designed to facilitate workflow automation in companies of all sizes. Our team of development experts is ready to help you implement customized solutions that maximize the performance of your processes. Want to take your management to the next level? Contact us today and discover how workflow automation can transform your organization. In addition, we invite you to visit our YouTube channel, where you will find a complete tutorial on workflow automation for overtime. Subscribe now and take advantage of all our exclusive resources to optimize your productivity!
Leave a Reply