Freigeben über


Microsoft Flow | SharePoint Online Alerts | Get list of users subscribed to out of the box SharePoint Alerts

Sceanrio: Get the list of Users subscribed for Out of the box SharePoint Online Alerts per site/subsite.

It has been a long waited requirement from SharePoint users and Admin globally and an ask to Microsoft to provide a way toget a list of all users who have subscribed alerts on lists/libraries or any object in a SharePoint Site or a subsite. After what feels like a lifetime, Microsoft released Rest APImethods for SharePoint Alerts and very recently I had to use them to Getand Deleteuser alerts using REST API call for a project.

Today, I will be showing How to Get the list of All Users subscribed to alerts for a Site or a Subsite and next blog will be to How to Delete alerts for a specific List or a Library using REST API method in Microsoft Flow.

Solution:

1. You need to get Access Tokenfor the SharePoint site. I have listed to very commonly browsed articles for same in this Article. Same steps in My MS Flow looks like below.

2. Initialize the Variable. The Output generated from REST API is in Array form. so we need to get only the Results body from  "/_api/web/alerts?$expand=user"  and store it in a Global Array variable. 

3. Now it gets a bit tricky. I am retrieving only "User Email", "User Display Name" (which comes as Title in REST API results and the "List Title" to which the alert is subscribed to.

This is Uncollapsed screenshot, below I will break it up for better understanding.

Here, from the Original Array results of HTTP REST API call, we will store the values in variables.

In "Create HTML Table" I had kept "Include Headers" as "No", but there is a bug I reported to Microsoft HERE.

Final Step is sending mailto yourself with the output of the HTML table created.