+91 – 88617 28680learning@flexmind.co

How to Schedule a Flow to Notify Before Document Expiration

14
Oct

How to Schedule a Flow to Notify Before Document Expiration


We always need a solution on How to Schedule a Flow to Notify Before Document Expiration in SharePoint. Today we will build a solution using email configuration list to achieve this task. I know we can set alert on document library to notify ourselves. But this solution will use external custom list to set alert on multiple libraries.

Agenda to build this solution

  • Create a custom configuration list
  • Create and Schedule a MS Flow to send notification

We will look each steps in detailed to build this solution.

Create custom SharePoint configuration list

In this step we will create a SharePoint list as shown in below picture. We will add three columns; “LibraryName”, “ColumnName” and “NoOfDaysBeforeExpiry “. We will name this list as “Document_Expiry_Email_Config“. Now we will add items to this list.

Figure 1

Create and Schedule a MS Flow

1 – Build a scheduled flow as shown below.

Figure 2

2 – Pass all the parameters and click create button.
3 – After recurrence step add Get Items action

Figure 3

4 – Add apply to each step and select value from previous Get Items.

Figure 4

5 – Inside apply to each block add another Get items 2, Compose and Compose 2 action blocks.

Figure 5

6 – Pass values for all the action block shown in Figure 5.
7 – Add one more apply to each 2 action block below compose 2. Basically this loop will run through all the items of the library.

Figure 6

8 – Inside apply to each 2 add a condition block.
9 – Now we will demystify the condition step. Here we are comparing the Expiry date of current item with notification date. Notification date can be set dynamically using Document_Expiry_Email_Config list.

Figure 7

Before jumping into the LHS and RHS of condition segment, I would suggest to get current item of apply to each 2 loop as a string. Format that string using online JSON formatting tools. It will look like something below.

Figure 8

Formula for condition block are given below:
L.H.S -> item()?[outputs(‘Compose’)]
In above formula we are querying the current item of apply to each 2 loop.
R.H.S -> formatDateTime(addDays(utcNow(),int(outputs(‘Compose_2′))),’yyyy-MM-dd’)

10 – If condition meets, then we will send the notification email as shown below.

Figure 10

Formula for different fields used in above screen shot are given below.
Author’s Email -> item()?[‘Author’] ?[‘Email’]
Author’s Display Name -> item()?[‘Author’] ?[‘DisplayName’]
Document Name : item()? {Name}
Expiry Date : item()?[outputs(‘Compose’)]
Link to Document : item()? {Link}

After performing the above steps it will send a sample email like below.

Figure 11

Hope you will like this post, please share and subscribe our site for more stuff on Flow and PowerApps. You can visit our old blogs by clicking on link. For more details on MS flow follow this link.

Leave a Reply