Forum Discussion
SharePoint Modern Page - Notifications when submitting Comments
- 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)/validateUpdateListItemand 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)
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)
- mvnairSep 19, 2024Copper Contributor
Thanks Rob.
I wish I saw this post sooner as I found these steps on another resource and implemented the flow, only difference was that I didn't have to use the format "i:0#.f|membership|" but I used a manual trigger with input email control to enter Created By and Modified By fields as for me this was a one time task on one .aspx page in Site Pages.So if I peek the code this is how it looks:
"FieldName": "Editor", "FieldValue": "[{'Key':'@{triggerBody()?['email']}'}]"
Thanks this is fixed now.