Introduction

In this article, we will see how we can read the files’ file properties in a SharePoint Online document library folder and send these properties in tabular format with custom CSS styling in the email notification.

Create a JSON button to send a notification

In the SharePoint library, add a SharePoint field ‘Send’ of type Hyperlink or Picture.

Use the option ‘Format this column’ for the SharePoint field ‘Send ‘ to apply JSON formatting to create a button for triggering flow. Use below JSON code.

{
“$schema”: “https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,
“elmType”: “button”,
“customRowAction”: {
“action”: “executeFlow”,
“actionParams”: “{\”id\”: \”v1/fa99b09d-825d-49e5-bd89-c10f0/ac5e42b0-ff62-40ba-a6ac-cb589e274\”}”
},
“attributes”: {
“class”: “ms-fontColor-themePrimary ms-bgColor-themeDark–hover ms-fontColor-themeLighter–hover .ms-ContextualMenubutton”
},
“style”: {
“cursor”: “pointer”,
“display”: “=if([$PermMask]>=’0xb00′, ‘none’, ”)”
},
“children”: [
{
“elmType”: “span”,
“attributes”: {
“iconName”: “MicrosoftFlowLogo”,
“class”: “ms-font-xxl”
},
“style”: {
“padding-right”: “6px”
}
},
{
“elmType”: “span”,
“txtContent”: “Send Notification”
}
]
}
This will add the following button to the SharePoint field.
 
When you click this button at the folder level, it will run a flow that will get all the properties of all the documents in that folder, apply some styling and send it in an email as a table.
 
Flow for sending notification
 
First i have created the sharepoint list with the name of Send Notification 
 
i have add the columns to the list.
 
Use SharePoint trigger For a selected item
 

Initialize a string variable varTabStyle to set the table’s styling inside the notification’s email body.

Below is the value of this string variable for CSS styling. You can use your own CSS styling.

<style>
table {
border: 1 px solid #b3adad;
border – collapse: collapse;
padding: 5 px;
}
table th {
border: 1 px solid #b3adad;
padding: 5 px;
background: #f0f0f0;
color: #313030;
}
table td {
border:1px solid # b3adad;
text – align: left;
padding: 5 px;
background: #ffffff;
color: #313030;
}
</style>

Get all files properties inside the SharePoint folder

Use the SharePoint action Get files (properties only) to get properties of all files inside a folder. You have to select your site, document library, and folder name.

Create an array of files properties

What does Select Action do? Use Select action. Select the specified properties from all elements of the ‘From’ array into a new one.

Our previous action gives us an array of all document properties in a given folder. Using the Select action, we are creating another array of custom properties for documents we want to show in our email notification.

Next, we will use Create HTML table action to create html table from this array. This action uses the output of the previous action to create html table.

Finally, use Send an email (V2) action to send an email with a formatted html table having document properties. Use vartabstyle for styling and output of Create HTML table action for document properties data.

We need to save the flow then we need to go our sharpoint and click on button “Send Notification”.

The table in the email notification will look like the one below. It has all the CSS styles applied to html table.

Summary

In this article, I discussed how to create a custom flow to send an email notification with formatted data in the form of html table. We use custom CSS inside flow to format the html table inside the email body. We are using SharePoint trigger; for a selected item to trigger this flow, click the JSON button created in the SharePoint library field.

Some known limitation of this flow is that you can use it only if you are part of the Owners group in SharePoint. Another limitation is that this flow will trigger only when you create it in the Default Power Platform environment. In other custom environments, this will not work. I hope Microsoft will soon come up with a solution for these limitations.

For any Help or Queries Contact us on info@crmonce.com or +918096556344