Power Automate Flow for SPM Contractor HSSE Risk Assessment
This project focuses on creating a Power Automate flow to automate the processing of responses from the SPM Contractor HSSE Risk Assessment Microsoft Form.
Power Automate Flow for SPM Contractor HSSE Risk Assessment
Description
In this project, you'll learn how to develop a Power Automate flow to handle and manipulate data from a Microsoft Form with extensive branching logic. The flow will analyze responses to determine the HSSE Risk Level and generate a corresponding PDF output tailored to the specific mode and responses provided. By the end, the flow will also send an email with the selected data to a specified email address.
The original prompt:
I need help developing a Power Automate Flow. I have very little experience with Power Automate. Please tell me step by step how to build a Power Automate flow based on the following. Please explain it on a level of someone with no experience with Power Automate and for every step you tell me to do, tell me the reason why you are telling me to do it and give definitions of power automate terms and functions you have me to do as well. Here are the details of the flow I need: I have already built a Microsoft Form called SPM Contractor HSSE Risk Assessment. It has 10 questions. Here they are listed below, and in parentheses next to each one I will tell you the type of Microsoft Forms question it is and what the options are under each and the branching details if applicable. Everything in parenthesis are instructions and information for you. The form has branching that is based on 3 modes: Mode 1, Mode 2, and Mode 3, and one last option of, “Multi-Mode.
. Each has a different path and questions. Here are the questions of the Microsoft form entitled SPM Contractor HSSE Risk Assessment:
1. Type the name of this scope (This is a text question).
2. Please provide a short description of the scope of work to be performed by the contractor (This is a text question).
3. What is the Contract Mode of the scope of work to be performed? (This is a choice box and has branching. The choices are below for this question)
a. Mode 1 - (This one has branching that goes to the following choice check box options The question for this branch option is 4 below, but it is for “Mode 1 above”. The answers below will be used in the flow to determine the HSSE Risk Level.):
4. Please check which activities may be part of the scope of work to be performed by the contractor? Check if answer is 'Yes'. leave blank if 'No'. Here are the options for this one: Will work activity require a Hot Work Permit? (Below are the questions the user has to check the boxes for if the answer is yes, and they leave the box blank if the answer is “No”. I will need the responses to these questions in the flow later. They will determine the level of HSSE Risk Level. If the box is checked for each of the questions below in section 4, it will correlate to an HSSE Risk Level. The HSSE Risk Levels are High, Medium, and Low. If no box is selected for the questions below in section 4, then the HSSE Risk Level is Low. If the HSSE Risk Level is low, then put on the output PDF, “HSSE Risk Level: LOW”. If a box is checked in the questions below for section 4, then HSSE Risk Level will be either HIGH or LOW. The way you will tell if each questions is HIGH or LOW is based upon whether HIGH or LOW is in brackets like these [HIGH] or [LOW] at the end of each question. If you find at least one question in the section 4 list below that has [HIGH] below then the HSSE Risk Level for the entire form is HIGH, and you will print on the PDF output: “HSSE Risk Level: HIGH” )
Will work activity require a Hot Work Permit within a Process Unit? [HIGH]
Will work activity be located above 6 feet requiring the use fall protection equipment? [HIGH]
Will work involve Confined Space Entry / Restricted access or egress / trenching? [HIGH]
Other than driving to and from a job site, are there other potential hazards associated with vehicle movement while on company property? [MED]
Will work require process isolation? [HIGH]
Will work involve heavy lifting or hoisting controlling of a Suspended Load? [HIGH]
Will gas testing be required before or during the work activity? [MED]
Will work activity require obtaining authorization before overriding or disabling safety critical equipment? [MED]
Will work activity be within a live Process Area Flare Zone? [MED]
Will work involve the use of tools or equipment that have the potential to result in serious harm or injury to self or others? [MED]
Will work activity be near other people that may result in serious harm or injury? [MED]
Will the work activity require the use of specialized tools or equipment? e.g. High-pressure water or hydraulic systems. [MED]
Will the work activity require the use of Respiratory Protective Equipment? [MED]
Will any of the following hazards be present during the work activity: Pressure (+/-), Flammable Materials, Toxics, Thermal (hot/cold), Radioactive Sources. [MED]
There are other potentially hazardous activities not listed above.
(All of the questions above are check boxes that at least one must be check. Once they are checked they go to Section 5 which is a text box. Section 5 is below).
Section 5. Are there other potentially hazardous activities not listed above? (This is a yes or no choice question, but it is also a branching question. The answer to this one will be a text answer that needs to be output on the PDF.)
b. Mode 2 - (This option, Mode 2, when selected branches to 4 below).
4. If you have already identified some prospective suppliers to perform this scope, please list them below (This is a text box question. I will need the text box response of this question put in the output which is a pdf, and you will have to use it to determine what the output will be).
c. Mode 3 – (This option, Mode 3, when selected branches to 4 below. 4 below has check boxes. I will need to know which ones in 4 below are checked off by the person that responded. The ones that are check off will be used to determine the HSSE Risk Level which will then be output in the pdf).
4. Does the scope of work to be performed involve any of the circumstances described below? (I will need the check box response of this question put in the output which is a pdf, and you will have to use it to determine what the output will be. Each check box question below is separated.)
Transportation of people (including Shell and/or contractor personnel) and/ or goods is the primary scope provided (e.g. . freight forwarding, bussing, air transportation, etc.).
The scope includes Shell personnel performing physical work or activities at a 3rd party location (e.g. active training, HSSE risk activities at third party facilities (e.g.)
Scope taking place in a Contractor operated facility (e.g. warehouse, workshop, etc.), that is estimated to make up more than 50% of the facility's capacity at any one time.
Scope taking place in a public location (e.g. public roadway, etc.).
None of the above are anticipated to be included in the scope of work.
(This Mode 3 option now goes to Section 6 below which is a text box. The answers given by the responders will need to become output in the PDF output at the end of the flow)
Section 6 Please describe other potentially hazardous activities not listed above. If N/A, hit the submit button below.
Multi-Mode (This is another option. If this one is chosen by the responder, the responder will have to select at least one of the questions in sections 4, 5, 6, and 7 below. The selections that the responder clicked will need to be emailed to Mark.Kennedy2@shell.com ).
Section 4
What activities may take place as part of the scope of work to be performed by the contractor on-site? Check if answer is 'Yes'. leave blank if 'No')
Will work activity require a Hot Work Permit?
Will work activity require a Hot Work Permit within a Process Unit?
Will work activity be located above 6 feet requiring the use fall protection equipment?
Will work involve Confined Space Entry / Restricted access or egress / trenching?
Other than driving to and from a job site, are there other potential hazards associated with vehicle movement while on company property?
Will work require process isolation?
Will work involve heavy lifting or hoisting controlling of a Suspended Load
Will gas testing be required before or during the work activity?
Will work activity require obtaining authorization before overriding or disabling safety critical equipment?
Will work activity be within a live Process Area Flare Zone?
Will work involve the use of tools or equipment that have the potential to result in serious harm or injury to self or others?
Will work activity be near other people that may result in serious harm or injury?
Will the work activity require the use of specialized tools or equipment? e.g. High-pressure water or hydraulic systems.
Will the work activity require the use of Respiratory Protective Equipment?
Will any of the following hazards be present during the work activity: Pressure (+/-), Flammable Materials, Toxics, Thermal (hot/cold), Radioactive Sources.
5
Do any of the offsite activities involve any of the circumstances described below?
Check any activities that form, or may form, part of the expected scope of work.
Transportation of people (including Shell and/or contractor personnel) and/ or goods is the primary scope provided (e.g. . freight forwarding, bussing, air transportation, etc.).
The scope includes Shell personnel performing physical work or activities at a 3rd party location (e.g. active training, HSSE risk activities at third party facilities (e.g.)
Scope taking place in a Contractor operated facility (e.g. warehouse, workshop, etc.), that is estimated to make up more than 50% of the facility's capacity at any one time.
Scope taking place in a public location (e.g. public roadway, etc.).
None of the above are anticipated to be included in the scope of work.
6
If you have already identified some prospective suppliers to perform this scope, please list them below.
If no, please leave blank.
7 Please describe other potentially hazardous activities not listed above. If N/A, hit the submit button below.
(
Microsoft Power Automate is a cloud-based service that enables you to create automated workflows between your favorite apps and services to synchronize files, get notifications, collect data, and more.
Access the Dashboard: Once signed in, you will see the Power Automate dashboard.
Creating a New Flow for SPM Contractor HSSE Risk Assessment
Step 1: Create a New Flow
Navigate to My Flows:
From the left-hand menu, click on "My flows".
Click on "New flow" and select "Automated cloud flow".
Set Flow Parameters:
Name your flow (e.g., "SPM Contractor HSSE Risk Assessment Automation").
Choose the trigger "When a new response is submitted" from the Microsoft Forms connector.
Click on "Create".
Step 2: Setting Up the Trigger
Configure Form Trigger:
Under the trigger "When a new response is submitted", select your Form from the "Form Id" dropdown (ensure your form is already created in Microsoft Forms).
Step 3: Get Response Details
Add New Step:
Click on "New step".
In the "Choose an action" box, search for "Forms".
Select "Get response details".
Configure Get Response Details:
In the "Form Id" dropdown, select your Form.
In the "Response Id" field, select "Response Id" from the dynamic content.
Step 4: Process the Response
Process the Form Response:
Add a new step if you wish to process the data, such as storing it in a SharePoint list or sending an email.
Example Action - Create Item in SharePoint:
Click on "New step".
Search for "SharePoint" and select "Create item".
Configuration:
Site Address: Select the SharePoint site where you want to store the data.
List Name: Select the name of the list.
Map your form responses to the relevant SharePoint columns using the dynamic content.
Example Action - Send an Email:
Click on "New step".
Search for "Outlook" and select "Send an email (V2)".
Configuration:
To: Input the recipient(s).
Subject: Create a subject line (e.g., "New HSSE Risk Assessment Submitted").
Body: Customize the email body with the relevant content and dynamic fields from the form response.
Step 5: Save and Test
Save the Flow:
Click on "Save" at the top right corner.
Test the Flow:
You can test the flow by submitting a new response to the form. The flow should trigger and execute the configured actions.
Conclusion
By following these steps, you have created an automated workflow using Microsoft Power Automate to process responses from the SPM Contractor HSSE Risk Assessment Microsoft Form. This workflow can be further customized based on additional requirements and processes.
For more complex scenarios or additional customization, you can explore Power Automate's extensive library of connectors and actions.
Setting Up Microsoft Forms and Understanding Branch Logic
Step 1: Creating the Microsoft Form for SPM Contractor HSSE Risk Assessment
Create the Form:
Go to forms.microsoft.com and log in with your credentials.
Click on New Form.
Title your form as "SPM Contractor HSSE Risk Assessment".
Adding Questions:
Add the necessary questions for your risk assessment. Ensure that the questions capture all required data points.
Use various question types like choice, text, rating, etc., depending on the requirement.
Step 2: Implementing Branch Logic in Microsoft Forms
Access Branch Logic:
Click on the three dots (...) at the top right of a question.
Select Branching.
Setting Up Branch Logic:
Identify a question that directs the respondent to different subsequent questions based on their answer.
For example, if you have a question "Is the risk level high?" with options "Yes" and "No":
If "Yes" is selected:
Branch to a question that asks for more details about the identified high risk.
If "No" is selected:
Skip to the next section or end the form.
Finalizing Branches:
After you set up your branches, navigate through the branching logic to ensure it follows the correct path for each scenario.
Click on Back to exit the branching setup.
Step 3: Creating a Power Automate Flow to Process Form Responses
Start Flow Creation:
Go to flow.microsoft.com and log in with your credentials.
Click on Create and select Automated Flow.
Configure Trigger:
Choose the "When a new response is submitted" trigger from Microsoft Forms.
Select your HSSE Risk Assessment Form from the dropdown list.
Get Response Details:
Add a new action Get response details.
Specify the Form ID and the Response ID from the previous trigger.
Processing the Response:
Add actions to process the response as per your requirements. For instance, you might:
Compose Action: Extract and organize form data.
Condition Action: Implement decision-making based on form responses, e.g., if the risk level is high, send an alert email.
Create a SharePoint Item: Store responses in a SharePoint list for record-keeping and further analysis.
After adding all necessary actions, save the flow.
Test the flow by submitting a few sample responses to ensure that it processes the responses correctly and performs the expected actions.
Summary
By following these steps, you will have a Microsoft Form with branching logic tailored for HSSE risk assessment. Additionally, Power Automate will handle real-time processing of the responses, ensuring that any necessary actions are taken based on the form data. This setup allows you to automate and streamline the risk assessment process efficiently.
Creating a Basic Flow in Power Automate
Objective: Automate the processing of responses from the SPM Contractor HSSE Risk Assessment Microsoft Form.
Step-by-Step Implementation
Step 1: Open Power Automate
Navigate to the Power Automate portal by entering https://flow.microsoft.com in your web browser.
Sign in with your credentials.
Step 2: Create a New Flow
Click on Create in the left-hand side navigation menu.
Select Automated cloud flow.
Step 3: Define the Trigger
In the Build an automated flow window, provide a flow name like "SPM Risk Assessment Response Processor".
In the Choose your flow's trigger search box, type "Forms".
Select When a new response is submitted from the list.
Click on Create.
Step 4: Configure the Trigger
In the Form Id dropdown, select the SPM Contractor HSSE Risk Assessment form.
Step 5: Get Form Response Details
Click on + New step.
In the search box, type "Forms" and select Get response details.
Configure it as follows:
Form Id: Select the SPM Contractor HSSE Risk Assessment form.
Response Id: Select Response Id from the When a new response is submitted trigger.
Step 6: Add Conditions to Process Responses
Click on + New step.
Search for Condition and select the control.
Configure the condition:
Choose a value: Select a field from the form response that you want to apply logic on, e.g., "Risk Level".
Condition: Select the condition, e.g., is equal to.
Value: Set the value to check, e.g., "High".
Step 7: Specify Actions Based on Conditions
If the Condition is Met:
Within the If yes branch, click Add an action.
Select an action to perform, e.g., send an email notification.
Type "Outlook" in the search box and select Send an email.
Configure it with recipient, subject, and body including form response details.
If the Condition is Not Met:
Within the If no branch, click Add an action.
Select an appropriate action, e.g., notify a different team or log the response in a SharePoint list.
Type "SharePoint" in the search box and select Create item.
Configure the SharePoint details including site address, list name, and columns to populate.
Step 8: Save and Test the Flow
Click on Save in the top right corner.
Perform a test by manually submitting the form and verifying that the flow triggers and processes the response correctly.
That's it! You now have a basic flow that automates the processing of responses from the SPM Contractor HSSE Risk Assessment form in Power Automate.
Advanced Data Handling and Conditional Logic in Power Automate
Objective:
Automate the processing of responses from the SPM Contractor HSSE Risk Assessment Microsoft Form using Power Automate with advanced data handling and conditional logic.
Prerequisites:
A Microsoft Form named "SPM Contractor HSSE Risk Assessment" is already created.
A basic Power Automate flow is already created.
Microsoft Power Automate environment is set up.
Steps:
1. Initialize Variables
First, let's initialize the necessary variables to handle your data effectively.
Add a new step after your trigger and select "Initialize variable".
Set the Name to riskLevel, Type to String, and Value to an empty string "".
After setting the riskLevel, you can use this variable to take further actions, such as sending notifications or updating a database.
Add a new step to notify the concerned team with the risk level.
Select "Send an email" action:
To: team@example.com
Subject: HSSE Risk Assessment Notification
Body: The risk level for the recent assessment is: @{variables('riskLevel')}
{
"inputs": {
"to": "team@example.com",
"subject": "HSSE Risk Assessment Notification",
"body": "The risk level for the recent assessment is: @{variables('riskLevel')}"
}
}
Summary:
In this section of the project, you have implemented advanced data handling and conditional logic in Power Automate to process HSSE Risk Assessment responses effectively. By initializing variables, parsing JSON responses, applying conditional logic, and using the result for further actions, this setup ensures automated and efficient processing of form responses.
Part 5: Generating PDFs and Sending Emails in Power Automate
Prerequisites
A Microsoft Form titled "SPM Contractor HSSE Risk Assessment" with the required fields and response data.
A connected Power Automate environment.
Access to Microsoft 365 services including Forms, OneDrive, SharePoint, Outlook, and the Microsoft Power Automate connectors.
Steps to Create a Power Automate Flow for PDF Generation and Email Sending
1. Trigger the Flow from Microsoft Forms
Go to Power Automate.
Create a new flow: 'Automated-from blank'.
Choose "When a new response is submitted" trigger for "Microsoft Forms".
Select your form "SPM Contractor HSSE Risk Assessment".
2. Get Response Details
Add a new step: "Get response details".
Specify the Form ID and the Response ID from the previous form trigger.
3. Compose PDF Content
Add a new step: "Compose".
Create the HTML content for your PDF file. Use the dynamic values from the 'Get response details' action.
Add a new step to "Convert HTML to PDF". If you do not have a direct connector, you may use "OneDrive" to create a HTML file and then convert it using another service like Encodian or Plumsail.
Example with Encodian:
Add the action: "Encodian Convert HTML to PDF".
For the Html field, map the output of your previous "Compose" action.
5. Save the PDF File
Add a new step: "Create file" in OneDrive or SharePoint.
Configure it to save the PDF generated in the previous action.
Please find attached the HSSE Risk Assessment Report for @{outputs('Get_response_details')?['body/ContractorName']}.
Best regards,
Your Team
Implementation Summary
You now have a Power Automate flow setup which:
Triggers when a new response is submitted.
Fetches the response details.
Composes an HTML representation of the response.
Converts the HTML to PDF.
Saves the PDF to OneDrive or SharePoint.
Sends an email with the PDF attached.
This flow automates the process of generating a PDF report from form responses and sending it via email, thus saving time and ensuring efficient documentation and communication.
Complete the flow and test it with a sample response to ensure all parts are working correctly.