Forum Discussion

mvnair's avatar
mvnair
Copper Contributor
Sep 13, 2024
Solved

SharePoint Modern Page - Notifications when submitting Comments

On a modern page when someone post a comment, notification is sent to person who created the page. I'm looking for an option to change this so notifications are sent to another person, tried changing...
  • Rob_Elliott's avatar
    Sep 16, 2024

    mvnair you can change the Created by column using some JSON and a small flow in Power Automate.

     

    Create a flow in Power Automate and make sure you add a text input for Owner Email; you will enter the first part of the new owner's email (before the @) when you trigger the flow from the list.

     

    For the Uri the syntax is
    _api/web/lists/getByTitle('Site Pages')/items(ID)/validateUpdateListItem

     

    and you select ID from the dynamic content box.

     

    The body of the Send an HTTP request to SharePoint is as follows and you select owner email from the dynamic content box.

    {
    "formValues":[
    {
    "FieldName": "Author",
    "FieldValue": "[{'Key':'i:0#.f|membership|{Owner Email}@wsp.com'}]"
    },
    {
    "FieldName": "Editor",
    "FieldValue": "[{'Key':'i:0#.f|membership|Owner Email}@wsp.com'}]"
    }
    ],
    "bNewDocumentUpdate": true
    }

     

    Save your flow and copy its ID as you'll need this next.

     

    In your site pages library add a single line of text column and format it with the following JSON. Change the id in the actionParams line to your flow's ID. Change the txtContent text to whatever you want and also change/add to the style. You can also change the text that triggers the flow; I've changed it to "Go".

     

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "button",
      "txtContent": "Change Owner",
      "customRowAction": {
        "action": "executeFlow",
        "actionParams": "='{\"id\":\"5eddbaca-e7df-46f4-b968-f009ed9f69ec\", \"headerText\":\" ' + [$Title] + '\",\"runFlowButtonText\":\"Go\"}'"
      },
      "style": {
        "background-color": "#fff5dd",
        "border-radius": "10px"
      }
    }

     

    That will add a button to each page in the library:

     

     

    When you click the button a panel will open for you to enter the first part of the email address of the new owner (created by):

     

    Once you click go the flow runs and after a few seconds the name is changed in the Created by column. That person will now receive notifications.

     

     

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)

     

Resources