Monday, March 19, 2018

Microsoft Flow | SharePoint Online Alerts | Delete multiple user Out of the box Alerts

Scenario: SharePoint Administrators would love to delete User alerts subscribed to a list/library in one go. But unfortunately there is no way in User Interface that is allowed, you have to do it one by one for every user which is not efficient and very time consuming.

In my Previous blog "Get list of Users Subscribed to OOB Alerts", you can get all Alerts which is also not possible via User Interface.

In this blog I will show how to Delete Alerts for a specific List and the task can be achieved in few seconds.

Below is how the Overall uncollapsed version of the Flow looks like. I will break it up further.

1. First we need to connect to the site. so HTTP REST API call to get the Alerts .

Compose data operation "Access Token' enter ' "@outputs('HTTP').body.access_token" ' (with double quotes which is in Bold

Compose data operation "Compose" enter ' "@outputs('HTTP_2').body.d.results"  ' (with double quotes which is in Bold

2. I am initializing a global variable and at the same time setting its output to "Compose" results, which will be the body of Alerts REST API from "HTTP 2" step. 

3. Next, adding an 'Apply for each' from the Array results, we will obtain only 'List title' and 'Alert ID' from the results. both are store in Compose action. 
             To get List Title " item()?['Title'] " (enter without the quotes, only text in bold)
             To get Alert ID " item()?['ID'] "  (enter without the quotes, only text in bold)

4. Next we are checking for a specific List from which we want to delete all the OOB Alerts. Add a Condition where 'Output of ListTitle' is equal to the List.

5. Last step of Alert deletion. If condition is met, we run another HTTP REST API method "DELETE". The syntax for delete is " /_api/web/alerts/deletealert('Alert ID') " . So we need to replace the 'Alert ID' with the output of the compose action where Alert ID of the current item is stored. ( Pls. Note: REST API Method call will be "DELETE" )

On a Successful Deletion once the Condition of List Title is met, HTTP Call for Delete Method will look like below.

Friday, March 16, 2018

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 to get 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 API methods for SharePoint Alerts and very recently I had to use them to Get and Delete user 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.


1. You need to get Access Token for 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 mail to yourself with the output of the HTML table created. 

Microsoft Flow | Get Access Denied for REST API SharePoint call

Scenario: Using Microsoft Flow you need to call HTTP Rest API methods and for that it needs Access Token authorization. You get "Access Denied" permissions error.

"Access denied. You do not have permission to perform this action or access this resource"

To Get Access Token for Authorization
There are many articles online regarding this topic and mostly viewed are below one, from where I got most of the knowledge too.

However, while creating my own Flow and trying to get access tokens, I have faced some issues even after following above 2 articles. one of them I have created an article on "Invalid Client Secret" key error.

Another issue I encountered was when working for subsites or O365 group sites. It would just give me "Access denied" permissions in response body even in POSTMAN. it would not work. Below is what I had to do to fix that.

Even if you are Site Collection Administrator, you will get this issue. Even if you have Trusted the APP with below code, you will get the "Access Denied" error.


After spending many hours and almost giving up, I modified the Trust App code to below and Wow! It worked. It worked for a Subsite and for O365 group site.


So, it is chance you can either use the first code or the second code while Trusting the APP. you cannot use both. Either of one should work. You do not need to create a new Trusted APP. for an existing APP also you can re-trust it with other 'AppPermissionRequest' tag and it will take the new one that you enter.

For more details on SharePoint App Permission Scope, please read this Microsoft Article

Saturday, February 24, 2018

Microsoft Flow | HTTP Rest API | Invalid Client Secret error

Issue: You Get "Invalid Client Secret" error even if the same secret key works fine in Postman.

Scenario: You are using HTTP action to call REST API for SharePoint. you successfully get the Access Token however, the same does not work in GET or POST method and errors out with "Invalid Client Secret". Even though the same client secret works perfectly fine in Postman tool.

I have mostly got this error when the Client Secret key has some plus (+) sign or equal (=) sign in the secret. otherwise it does not give me error.


You need to Encode the special characters.

For Example:- This is the Original client secret key. where we have + sign and = sign.


Encode the client secret as below. Replace + by %2B and = by %3D


Now if you run the flow it should work without any errors. 

More Information on special characters

The reserved character "/", for example, if used in the "path" component of a URI, has the special meaning of being a delimiter between path segments. If, according to a given URI scheme, "/" needs to be in a path segment, then the three characters "%2F" or "%2f" must be used in the segment instead of a raw "/".

Reserved characters after percent-encoding

%0A or %0D or %0D%0A
Common characters after percent-encoding (ASCII or UTF-8 based)

Arbitrary character data is sometimes percent-encoded and used in non-URI situations, such as for password obfuscation programs, or other system-specific translation protocols.

Microsoft Flow | Send mail to Multiple recipients from SharePoint Person Or Group field.

Scenario: you have a SharePoint List where a field with 'Person or Group' having multiple entries is selected. you want to send a mail to all the people entered in that field. However, currently that field is not supported in Microsoft Flow.

Steps on How to get multiple Entries from 'Person or Group' field in SharePoint List and send a single mail to them. 

In This example, I have a simple SharePoint List for Training Registration. Where in the Attendees field multiple people can be selected based on the Nominations. So below we have a field 'Attendees' as 'Person or Group' where 'Allow Multiple Selections:' is selected as "Yes"

  1. I am Triggering MS Flow when a new item is created in the Training Registration SPO List. 
  2. Next Step adding 'Get Item' action and fetching the item created via its 'ID'
  3. Next Step adding 'Data operations - Select' action. (this will take only an Array value as input)
    1. as the output of 'Get Item' will be an array, but I need only the attendees from that New Item created, in 'Select' Action 'From' (input for select) will be the 'Attendees' Field. 
    2. Map Key 'Attendees' to Value 'Attendees Email' (as only email can be used to send a mail.)
  4. Next we will use 'Initialize Variable' action. I named it as 'OriginalArrayAttendees'. Type as 'Array' and Value will be the Output from previous 'Select' action, we get only the Attendees Mail address in the array variable. 
  5. Next we will again use 'Initialize Variable' action. I name it as 'FinalStringAttendees'. Type as 'String' and Value as blank at this stage. 

Now we need to put all the Email addresses into a single variable separated by semi-colon (;) 
  1. Next Step -> Add 'Apply to each' where the output of variable 'OriginalArrayAttendees' is entered. 
  2. from that array, we need to concat all the email addresses with a semi-colon, so we add a 'Data operations - Compose' action and in expression enter "concat(item()?['Attendees'],';')". Pls. Note: Attendees in the concate is the 'Map Key' you gave in the above 'Select' action.
  3. Next step, we need to append the values in a single String variable which is 'FinalStringAttendees'
  4. Finally use 'Set Variable' action to get the concatenated string of all email addresses in variable so that it can be used out of the 'Apply to each' loop. Value of 'FinalStringAttendees' will be Output of 'Compose 2' action where we are appending all the values. 

Final step is send a Mail. using 'Send an email' action of O365 account. In the "TO" field it will be the 'FinalStringAttendees' variable. Rest of the body you can enter the way you want.

Microsoft Flow | How to send Single mail with Multiple SharePoint List Items.

What is achieved in this Flow?

  1. Run the Flow periodically on a schedule or on some other Trigger as per your choice. 
  2. Query a SharePoint List and GetItems (multiple rows)
  3. Create an HTML Table format with specific fields to be sent in a mail. 
  4. If the Output is Empty, Do not send mail, else send mail to specific recipients. 


  1. I am triggering this Flow on 'Recurrence Schedule' Trigger. 
  2. Getting Items from a SPO List only where the column 'Status' eq 'Request Placed' [ So I am doing OData Filter Query and getting only specific rows from a possibly large SPO List ] 
  3. Next step is the 'Data Operations Select' Action. [ This will take input Only from an Array Output ] 
    1. As the 'Get Items' Output is in Array, 'Select' action works great. The output 'Value' from 'Get Items' will be the Input of  'Select'
    2. 'Map' I am entering the headings of the Table and their values from output of previous steps which will be only those items where 'Status' field value is 'Request Placed'
  4. Next step is put the output of  'Select' Action to String, coz HTML Table action will not take an Array value as Input. so we need to use 'Data operations - compose' Action and put the output of 'Select' in Compose action
  5. Next Add 'Create HTML Table' Action -> Output will be from the 'Compose' step. (by default headers are created in HTML table action Advanced options)
  6. Next I am checking a Condition output is blank (this can be done for any step, it was just easy for me to enter the select output), I wanted to send separate emails if blank and if not blank. So instead of "@empty(body('Select'))" it could also be "@empty(body('Compose')) or "@empty(body('Get_Items'))"

After checking the Condition, I am sending different mails when the condition is True and False. If the condition is False, the output from 'Create HTML table' will be sent in body of the Mail. 

Tuesday, November 28, 2017

Get Task ID from Microsoft Planner Task

How to get the Task ID or Plan ID or even Group ID if you are creating a Plan in O365 groups?

I was trying to get this for Microsoft Flow and searched internet, but did not get any clue. Suddenly it clicked me that everything is URL based.

1. you Click on the Plan/Task for which you want to get the Task ID.
2. From the Browser copy entire URL to Notepad

You will see all the ID's in the URL


so in this case the taskID I needed to use in my MS Flows was "bfdr71NIqkqrDdXxrerNTJYAEL81"

I enter just that string and my Flow was accepting the value and working fine. 

Thursday, March 21, 2013

Certificate error for Federated Domains on O365

One of your on-premises Federation Service certificates is expiring. Failure to renew the certificate and update trust properties within 13 days will result in a loss of access to all Office 365 services for all users. Update now

Follow the articles below in that order.

1. - On the On-Prem ADFS server, Resolution 2, only PS Commands
 Add-PSSnapin Microsoft.Adfs.Powershell
 Update-ADFSCertificate -CertificateType: Token-Signing
2. - Run the commands in this article.

Wednesday, March 20, 2013

Map Network Drive / WebDav with SharePoint Online O365

WebDav with SharePoint Online O365

Issue: While Mapping a Drive to SharePoint Online it fails with below error.

The Mapped Network Drive could not be created because the following error has occurred.'Access Denied'. Before opening files in this location, you must first add the web site to your trusted sites list, browse to the web site and select the option to login Automatically.

  1. Open IE -> Go to ‘Internet Options’
  2. Select ‘Security’ tab -> Select ‘Internet’ Zone.
  3. UnCheck the box for ‘Enable Protected Mode’

Issue: You are using SharePoint workspace and when you try to save the file opened from Workspace. The Save location changes to local machines Temp folder instead of SharePoint Online Library from where the file was accessed. While Saving or ‘Save As’, the location should default to the SharePoint Online library itself and not the local machines temp folder.

Check / Troubleshoot:
  1. Make sure the ‘Web Client’ service is started on the client machine.
  2. Open the SPO site -> go to the Document Library
  3. Select ‘Open with Explorer’ [ Make sure this is working fine ]
  4. Delete IE Cache.
  5. In IE ‘Trusted Sites’ zone add ‘https://*’
Note: This is basically working on the WebDav functionality to work which is related to “Open in Explorer” mode from a SharePoint Document library. If you notice that the library does not open in Explorer Window from the site directly, your Save As option will redirect you to temp folder instead of the Site URL.
Note: Some users may complain that after certain period of time the mapped drive disconnects or they are asked to enter the credentials again for O365. This will happen if the time period has extended over 8 hours. This is default behavior by Design. They will need to refresh the credentials. This may also occur if users have not selected “Keep me signed in” checkbox while they sign in through Microsoft Online sign-in assistant.
Users can't sign out of Office 365 web services
Note: This is a known issue with Office 2013 64bit version. it will not work.

Step by Step configuration to Add custom Refiners in the Refinement Panel of Search Results page for SharePoint Online

You may have custom Library/List columns created which you would like to show them in the Refinement Panel on the Search Results.

Step 1: Creating a Document
Library / List with Customer Columns

  1. Create a New Document library -> go to Library Settings
  2. Create a new Column “Product Type” – Choice Field is what I selected.
  3. Upload some documents to the library and give different Choice options.


4. Go to Library Settings -> Advanced Settings -> Click on ‘ReIndex Document library’ Button.


Step 2: Creating a New SiteCollection or Sub Site using “Enterprise Search Center” template. (Note: the reason we need to do this is due to the fact that we
cannot modify the OOB ‘osssearchresults.aspx’ page)

I created a Subsite under my site collection using the ‘Enterprise Search Center’ template. Make sure that you are able to search the documents uploaded.
Step 3: Configuring Managed
Properties for Search

  1. Logon to Microsoft Online Portal (MOP)
  2. Go to SharePoint Online Administration Center page.
  3. On the Left Panel -> Select ‘Search
  4. Click ‘Manage Search Schema
  5. Search for Existing Managed property ‘RefineableString00’ -> Edit the property and set it up as per below. -> Click 'OK'

Note: By Default in SharePoint Online you cannot create a new Managed Property as ‘Refineable’, due to which we need to use the existing ones and give an Alias for that.

 Note: List of Default Existing Refineable Property list. 
Step 4:Adding the Managed Property to Refinement Panel on the Search Results Page
  1. Go to the Subsite Search Center site created in Step 2.
  2. Type in any keyword to go to the ‘Results.aspx’ page. -> ‘Edit’ that page.
  3. Edit the Refinement Panel web Part. -> Click on ‘Choose Refiners…’ button.
  4. From the list of ‘Available Refiners’ -> Select ‘RefineableString00’ -> Click ‘Add’ button.
  5. Change the ‘Display Name’ for it (Initially it may not show the Sample Values, wait for around 5-10 mins to take effect )
  6. Click ‘Ok’ -> Save and Close the Page -> Check-In and Publish the Page

Now when you perform the Search for documents in that library, on left Refinement Panel you will see the new Refiner “Product Type


Total Pageviews