In the first part of this series, here I established an application I wrote to improve incident management at the club I am proud to chair.
Requirements
- Centralised, secure list of incidents - (Part 1)
- Ability to add divers to list for trials or competitions (Part 1)
- Data entry must be easy and not time-consuming (Part 1)
- Weekly notification of all incidents to the welfare officer
- Email to parent or guardian of the diver when an incident is raised
- Escalation to welfare officer and others in the organisation for serious incidents
- Not cost anything
In this part I will walk you through the flows I used to notify parents and the welfare officer. There is also a requirement to escalate, notify immediately for serious incidents.
Weekly Notification
To allow our welfare officer to monitor all incidents and any patterns, it was requested that they receive a weekly overview of all incidents raised that week.
To do this, I created a flow using the recurrence trigger.
Using these options, the flow will trigger at 3 am every Sunday morning.
I then establish a variable for the email body and go off and retrieve all the items that have been created since last week. The filter query is used here to filter on all incidents that were created after 7 days ago, a simple addDays function used to get to the date 7 days ago
Next, just check to see if there are any incidents this week by checking the length of the returned list.
If this is greater than 0, then incidents have been created, go on to create an email, if not, just do nothing.
The next part is where I had to be a little bit clever, as the standard thing you would do did not give me enough flexibility. You could pass this list into a Create HTML function, but this put the data in a column format, where I wanted to display as a list going down the page, more of a normal email format.
Instead, I built up an email, formatting the content as I went. Starting with an apply to each, taking the Get Items from SharePoint command. The first action I used repeatedly in the creation of the email, which is stripping the html content from html aware fields in the columns of the SharePoint. Leaving these in resulted in a lot of mangled emails.
I then append to the Email Body string I created earlier a formatted HTML content.
The incident date is a simple formatDateTime function useage
formatDateTime(items(‘Apply_to_each’)?[‘IncidentDate’],‘dd/MM/yyyy’)
The next step is because Contacted field is a multi-choice option set. Again, I loop through the contents of the Contacted? field and append to the email body variable.
The final parts of the loop finish of the content for each incident
Finally, send out the email. Subject details how many incidents in the week with a count from the SharePoint items returned.
Email the Parent / Guardian
The next requirement was to notify the diver’s parent or guardian. For years, we had relied on slips of paper, which again is a GPDR nightmare. Using email was a sure fire way to ensure we have done our duty. This only applied for minor incidents, parents will certainly be involved a lot quicker for anything serious.
Firstly, trigger when a new item is created in the SharePoint list
Next, get the diver that is indicated in the list, diver id being the linking record between the incident list & members
As this SharePoint get items call may return more than one item, we have to place in a Apply to Each
Check to see if the diver has an email address (if new divers come on board, this might not be the case until we have their full details).
If no email, stop the action, otherwise send an email to the email to notify the parent.
Escalate an Incident
Most incidents, thankfully, require little follow up or after care. But, there are occasions that require our parent association to be notified along with insurance companies. We also have an internal follow up process for such incidents by our welfare officer.
Rather than create a new flow, after the flow above, I continue. Does the Contacted multiple select option set contain Ambulance or Police, both mean an immediate escalation. This is done by looping through the options selected and updating a variable if one of them matches either of the 2 conditions.
Further, there is a severe boolean on the form, so if that is triggered, also update the variable to true.
Finally, if Severe has been set, send an email