This blog will discuss how we can modify any SharePoint list item without changing its default columns value.
Here default columns refer to Created, Created By, Modified, and Modified By. [ID column cannot be updated]
Apart from the above-mentioned default columns, we can also update any custom column using this technique at once.
Sometimes, we need to add some columns and populate data in the live application. But we don’t want to affect the original author, editor, date of creation of the item, and the last modification.
We can directly update the column’s value through SharePoint, Power Apps, or Power Automate (Flow), but that will change the Modified by and Modified fields that we want to keep original.
Hence, we use the below-mentioned technique to modify the SharePoint List item without changing its default columns value.
In this demo, I’ll use a list name “Users” where I have the user’s First Name, Last Name, Date of Birth. Now I want to add the user’s email without changing its default columns value
Figure 1: SharePoint List without new column
Figure 2: SharePoint List with New email column
1) Open Power Automate by clicking here and selecting Create from the left pane and then choose Instant Cloud Flow, give your flow a name, select the manual Power Automate trigger, and click on Create.
Figure 3: Power Automate Navigation
Figure 4: Flow name and trigger
2) Add a new step, select Get Items SharePoint action, and select the site address and list.
Figure 5: SharePoint Get Items Action
3) Now add a new step, add Apply to Each action, and select the Value dynamic value in the Apply to each action.
Figure 6: Apply to each action
4) Add two compose actions to store the author’s and editor’s schema from the item. Refer to the picture below.
Figure 7: SharePoint Item’s Author
Figure 8: SharePoint Item’s Editor
5) We shall form a JSON that we shall use to POST data to SharePoint. This JSON data contains two properties (Field Name & Field Value).
In the field name, we will define the Field Name that we want to modify, and in the Field Value, we shall define the value that will patch into the defined field.
Here we shall also put the internal name of the custom email field that we want to update.
Figure 9: JSON Array of Fields
In the above picture, we want to update the Email and keep all the system fields the same as previous. In the Field Value, we will use the following expression –
Author: string(outputs('Get_Item_Author'))
Editor: string(outputs('Get_Item_Editor'))
Email: dipak@powersolution.dev [The email that I wanted to update]
Created: formatDateTime(items('Apply_to_each')?['Created'],'yyyy-MM-dd hh:mm:ss')
Modified: formatDateTime(items('Apply_to_each')?['Modified'],'yyyy-MM-dd hh:mm:ss')
6) In this step, we shall add a new action (Send an HTTP request to SharePoint) to post HTTP request to SharePoint and follow the below details –
Figure 10: SharePoint HTTP Request
Site Address: Select the SharePoint site.
Method: Post
Uri: _api/web/lists/getbytitle(‘Users’)/items(ID)/validateUpdateListItem
Here, Users is the list name where you want to Post the data.
ID is the ID dynamic content from above Get Items Action.
Body:
{
“formValues”:@{outputs(‘Form_a_JSON’)},
“bNewDocumentUpdate”:false
}
Save the flow. We will test the flow by clicking on the Test on the right top corner, selecting the Manual option, and clicking on the Test button. It will run the flow and add the Email without modifying the system default columns. Please see the picture below –
Figure 11: Before the update
Figure 12: After the update
In the above picture, you can see the Email is updated, and the system columns are the same as previous.
Well, this is the end of this post. You can add data in a live SharePoint list using the above process without affecting its system columns. Let me know if you have any queries or suggestions in the comment below. I will see you next time, till then, Happy coding! Contact us to learn more.
========
Read more
SharePoint Migration – Know basics before migration
Follow us: