Build a safety issue solution using SharePoint and Power Automate- Part 1

This blog post is inspired by this sharp, jagged piece of metal.

Sharp, jagged piece of metal.

I see this leg cutting, pant ripping piece of metal every morning when I walk into work and think to myself that I should report it. But by time I get to my office it’s out of sight and out of mind and no report is ever made. If there was a more timely and convenient way of reporting the safety issue, I’m sure it would be fixed by now.

In this blog series I’m going to use two of my favorite tools, SharePoint and Power Automate to make a Safety Issue Reporting and Tracking solution.

Let’s start by creating a SharePoint List to store the data associated with the Flow. My list is called “Safety Issue” and will have the following 3 columns:

  • “Picture” a Picture column type.
  • “Date Logged” a Date column type.
  • “Logged By” a Person column type.

Tip: Don’t use spaces in list names on creation. Spaces are converted to “%20”.

Spaces in list names become "%20"

It’s better, for example, to create our list as “SafetyIssue” and then rename it later as “Safety Issue”. Once created, the internal list name will remain as “SafetyIssue”.

No spaces in the list names means no "%20"

Tip: Use the “modern” list experience to add columns whenever possible. It will not replace spaces in column names with “_x0020_”. In “modern”, the internal name for “Date Logged” is “DateLogged”.

No spaces in column names means no "_x0020_"

In “classic””, the internal name for “Date Logged” is “Date_x0020_Logged”.

Spaces in column names become "_x0020_"

I set the “Title” column to not required by:

  • Clicking “Site settings” > “List settings” > “Title” > “Require that this column contains information:” = “No”.
"Title" column settings

Now we will create a Flow from within the “Safety Issue” list by:

  • Clicking “Flow” > “See your flows”
See you flows

Create a new “Instant – from blank” Flow by:

  • Clicking “New” > “Instant – from blank”.
Instant-from blank
  • Within the “Manually trigger a flow” trigger “Add an input” for “File Content”.
Manually trigger a flow
  • Add a SharePoint “Create item” action and then:
    • Set it to your site and list name.
    • Set the “Date Logged” column to “Date” from the “Manually trigger flow” trigger.
    • Set the “Logged by claims” to “Username” from the “Manually trigger flow” trigger.
Create item
  • Add a SharePoint “Add attachment” action.
    • Set it to your site and list name.
    • Set the “Id” to the “ID” column from the previous “Create item” action.
    • Set the “File Name” to “Timestamp” from the “Manually trigger flow” trigger plus “.png”. This is a hack for now and in my next blog post I will outline the steps to use JSON to parse out the file name.
    • Set “File content” to “File Content” from the “Manually trigger flow” trigger.
Add attachement
  • Add a SharePoint “Send an HTTP request to SharePoint” action
    • Set it to your site.
    • Set the “Method” to “Post”.
    • Set the “Uri” to “_api/web/lists/GetByTitle(‘Safety Issue‘)/items(ID).
      • Safety Issue is the external name of the list, note the space!
      • ID is from the “Create item” action!
    • Set the “Headers” to (using text mode):
      {
      "Content-Type": "application/json;odata=verbose",
      "X-HTTP-Method": "MERGE",
      "IF-MATCH": "*"
      }
    • Set the “Body” to:
      {'__metadata': {'type':'SP.Data.SafetyIssueListItem'},'Picture':
      {'Description': 'Timestamp.png',
      'Url': 'AbsoluteUri'}
      }
      • Timestamp is “Timestamp” from the “Manually trigger flow” trigger.
      • AbsoluteUri is “AbsoluteUri” from the “Add attachment” action.
      • Important there are single quotes around ‘Timestamp.png’ and ‘AbsoluteUri‘.
Send an HTTP request to SharePoint

My completed Flow looks like this:

Now we can test using the Power Automate mobile app:

  • Click “Buttons”.
  • Click your Flow, i.e. “Log safety issue – Part 1”.
  • Click “File Content” and then “Camera” to take a new photo or “Photo Library” to use an existing photo.
  • Click “Done” to start the Flow.

When the Flow is complete a new row is added to the “Safety Issue” list that displays a thumbnail of the safety issue, the date and who logged the issue. It’s not much but it will serve as the foundation for a larger solution.

Our scenario is pretty common, log concerns and have some one address it. We didn’t have to create a fancy app or over invest in development. We are all out of the box, all configuration and almost no code.

In my next blog post we will build on our safety issue solution and add more SharePoint functionality and Power Automate automation.

Thanks for reading.

NY

3 thoughts on “Build a safety issue solution using SharePoint and Power Automate- Part 1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s