Receive comment notifications by email in Modern SharePoint Pages

Manage comments on modern page is not easy specially if you are monitoring a lot of pages, this is a lack of functionality that I’m sure Microsoft will address in future updates.

I was challenged a couple times to try to build a solution to get notifications on new comments in modern pages, after a few tries I was able to put together a solution that notifies the owner of the page when a new comment is posted.

The solution is composed by an SPFx extension that is used to trigger the check on new comments, a modified page library with two extra columns and a Flow that ultimately sends the email.

Bellow you have all the steps involved to implement it.

Modify the Site Pages library

For each site where you want to implement this solution you will need to modify the Site Pages library to create to extra columns, the new columns will be used to track the number of comments.

To modify your library, do the following:

  1. Go to Settings and then Site Contents
  2. Open the Site Pages library
  3. Click on Add Column and select Number
  4. The name of the first column must be Previous Comments
  5. Select 0 for the Number of Decimal Places
  6. Type 0 for the Default Value
  7. Click on Add Column and select Number
  8. The name of the first column must be Actual Comments
  9. Select 0 for the Number of Decimal Places
  10. Type 0 for the Default Value

Previous Comments – Is the number of the comments returned for each page by the SharePoint API.

Actual Comments – Is the number of comments that was notified to the page owner.

Create the email notification Flow

To receive notifications by email you will need to use Microsoft Flow, for each execution of the Flow it will compare the number of Previous Comments with the number of Actual Comments, if the numbers are different the follow will send an email to the page owner.

To create your Flow do the following:

  1. Open Microsoft Flow
  2. Click on Create from Blank
  3. On the first trigger select SharePoint – When an item is created or modified
  4. Type the URL to your modern site
  5. If the Site Pages is not listed type it as a custom value
  6. Click on New Step and then Add a Condition
  7. Define the condition like the image bellow, this condition will check if the Actual Commnents column is empty
  8. For the Yes section
    1. Click on Add a new action
    2. Select SharePoint – Update Item
    3. Type the URL of your modern site
    4. If the Site Pages is not listed type it as a custom value
    5. On the ID field select the ID
    6. Type 0 on the Actual Comments
  9. For the No section
    1. Click on Add a Condition
    2. Define the condition like the image bellow, this condition will validate if there are new comments available
    3. For the Yes section
      • Click Add an action
      • Select SharePoint – Update Item
      • Type the URL of your modern site
      • If the Site Pages is not listed type it as a custom value
      • On the ID field select the ID
      • On the Actual Comments select the Previous Comments
  10. Click on Add an action
  11. Select Office 365 Outlook – Send an Email
  12. On the To field select the Created by Email
  13. For the Subject and Body you can use the Title and Link to item columns

Trigger the Microsoft Flow

To trigger the Flow a custom SPFx Extension was built, the extension is responsible to check the number of comments on each page and then update the Previous Comments column.

The code for the extension is available on GitHub and the package for the solution can be downloaded from this post.

Note: PnP PowerShell is required to install the solution.

To install the extension, do the following:

  1. Download the installation files file from here
  2. Open your SharePoint App Catalog
  3. Upload the SPPKG file to the App Catalog
  4. Check the option Make this solution available to all sites in the organization
  5. Execute the Install.ps1 file
  6. Provide the modern site URL where you want to apply the solution

Once the solution is installed you will see a button on the lower left corner of your window, this button will be only visible to the users with permissions to edit the pages.

When you click the button the Flow will be triggered, and all page owners will receive an update on new comments by email.

Download Comments Notifications
Explore Solution on GitHub

Thanks to Elio Struyf for the great article Getting likes and comments from modern pages it was fundamental to build this solution.

To watch this solution in action watch the video below

This solution was featured on the SharePoint Dev Weekly by Vesa Juvonen and Waldek Mastykarz, you can check their comments on the video below.

Designed by Freepik

19 Responses to “Receive comment notifications by email in Modern SharePoint Pages”

  1. jonas björkander

    August 15, 2018

    If we have alot of pages, it will render many many flows and most of us do have a limit on how many flows we can run and we might up using them all. Could we run through all pages in one batch/loop?

    • João Ferreira

      August 16, 2018

      Hi Jonas,

      Thanks for your feedback, I’ve been thinking about this but didn’t had the time to test any alternative.
      It might be possible following a similar approach described in this article, the idea is to use an auxiliary list to trigger the flow, and then the flow will iterate through all the pages in the library sending the email.
      If what I’m thinking is possible this approach will do 2 executions of Flow for each check on new comments.

  2. […] Receive comment notifications by email in Modern SharePoint pages – João Ferreira (BindTuning) […]

  3. Daniel

    September 18, 2018

    Hi Bastian!
    It may be because your Site Pages isn’t actually called Site Pages. For me they’re called Webbplatssidor (which is of course the Swedish translation for Site Pages). So when I changed the List name to the correct list name Actual Comments showed up.

    Kind regards

  4. João Ferreira

    October 10, 2018

    Hi Andrew,

    I tested the solution on my tenant and it is still working.
    Two possible thing can be happening on your solutions:

    1 – The extension is not enabled, make sure you checked the check box to make it available without feature activation
    On powershell execute this command let and check if the solution is listed.
    Connect-PnPOnline -url
    Get-PnPCustomAction -scope site

    Let me knwo what do you have listed

    2 – The account you are using do not have enough permissions to see the button, only users with edit permissions will see it.

    About notifying the user that made the comment, it is possible but requires a more complex structure and flow, but it can be an option.

  5. João Ferreira

    October 11, 2018

    Hi Andrew,

    Can you send me a screenshot of your page to my email?

  6. Rajsons

    November 14, 2018

    About notifying the user that made the comment, it is possible but requires a more complex structure and flow, but it can be an option. thanks

  7. Casey

    November 19, 2018

    How do we remove this? Tried Remove-PnpCustomAction and says Guid not found. Cool solution however the client does not want it anymore. thanks

    • João Ferreira

      November 19, 2018

      Hi Casey,

      To remove the solution execute the PowerShell cmdlets by the following order:

      1 – Connect-PnPOnline -Url
      2 – Get Get-PnPCustomAction -Scope site
      3 – Copy the id of the solution presented in the PowerShell console
      4 – Remove-PnPCustomAction -Scope site -Identity ID
      5 – Replace the ID by the ID of your solution

      • Casey

        November 28, 2018

        That worked great, thanks!

  8. Selva Kumar

    March 19, 2019

    Thanks for Sharing.. Read more about us..

  9. Shin

    April 18, 2019

    Hi João,

    First of all thank you for the effort in creating the webpart and this guide.
    I’ve stumbled on to the following issue. I was able to edit the library, create the flow and add the webpart. The webpart also triggers the flow. But the Previous and Actual comments numbers never change. Even if I make a comment and trigger the flow, it ends up not updating any numbers and not sending a mail. Because the result of previous comments > actual comments is always false.

    Do you have an idea why this happens? Thanks in advance.

    • Shin

      June 12, 2019

      Friendly reminder to check this question if possible. Thanks

    • João Ferreira

      August 21, 2019

      Hi Shin,

      By your description seems that the solution is not being executed on the page when you click on the button, please make sure the columns were created with the right name and type.
      I just implemented the solution on a new site and it’s still working as expected.
      After clicking on the button please open your browser console pressing F12 and let me know if there is any error there.

      Hope we are able to track down your issue.

      Have a nice day 🙂

  10. Pedro Francisco

    April 25, 2019

    Informativo , totalmente գue eu procurava.

  11. Ravi

    August 8, 2019

    thanks for sharing these great information. this is very help for us to managing website.

  12. visit

    November 21, 2019

    Nice information You master that and you have achieved god level

  13. link alternatif

    June 20, 2020

    Listing of Alternative Linksbo Backlinks
    Today is increasingly developing, rendering it simpler for people to access
    computerized networks. Till now there are many on-line gambling games that may
    be played by any person online. Therefore, betting lovers no extended need to
    go to the particular casino to try out wagering, this is quite effortless for them in order to play anytime in addition to anywhere without limitations.


Leave a Reply

I've been working with Microsoft Technologies over the last ten years, mainly focused on creating collaboration and productivity solutions that drive the adoption of Microsoft Modern Workplace.

%d bloggers like this: