Forum Discussion
Alerts on Comments in Modern Pages?
- Dec 29, 2017
Hi Rob,
I had a similar task: send the email notification to the author of the modern page in SharePoint online if the new comment added.
I have done this using MS Flow and MS Graph API because standard SharePoint actions in MS Flow didn't help me.
I've described the solution in https://www.infopulse.com/blog/using-microsoft-graph-api-inside-microsoft-flow-office-365/ on the public blog of my company.
Hope, it helps you.
UPDATE: This solution was implemented for teams site. We found new challenges for brand new communications sites.
Having tried a couple of different options I've gone with a Powershell script that uses PnPOnline to retrieve all my modern communication pages and then write any new commentcounts to a separate SharePoint list (or update an existing list item if the post already had comments previously). Then I have an alert setup on the list for any new or modified items. So far works really well. And the script was pretty straightforward to write (luckily, as I am not an expert Powershell guy by any means).
I did try Joao Ferreria's excellent solution and it worked well. The only drawback was that whenever we ran the code it modifies every modern page it checks so our last modified datetimes and users were changing regularly and it played havoc with various 'Most Recent' list views we have.
Would you be willing to share that script?
- Paul ChapmanMar 05, 2019Iron Contributor
Hi Gretchen, happy to share if it's useful.
The solution that I got working for us works as follows:
- Powershell script, running as a scheduled task, periodically reads the comment count for all News items (List A) on a given site.
- The comment count is compared to the comment count stored on a separate list (List B).
- If there is a comment for a News item that previously had no comments then a new item is added to List B with the article URL and the number of comments. If there is an additional comment for News article that already had comments then the list item in List B is updated.
- List B has an alert setup, going to our team Distribution List, whenever List B is added to or modified, which sends an Alert email including the URL of the article.
I don't know if that works for what you are trying to do. I have the script running on my local desktop as I had real problems getting the script task to run on a server with any sort of encryption. That may be a problem for you. Likewise, in my solution there are only ever 4 possible authors of the News items so for now I can send an alert to all 4, if you have lots of potential authors that may be no good, although I don't think it would take much to change the script to send an email to the article author once a new comment is found.
Hope that helps. Script attached (hopefully).
- Gretchen HustadMar 05, 2019Copper Contributor
Thanks so much! I'll get it to our more technical team members and see what we can do!
- Paul ChapmanMar 06, 2019Iron ContributorIf you could get them to correct the mistakes I made and send it back I'd be grateful! :)