This post is a contribution from Aaron Mio, an engineer with the SharePoint Developer Support team.
Lately. I came across an issue of using REST API ValidateUpdateListItem() to update listitem metadata. There’re a few blogs published on method ValidateUpdateListItem() for SharePoint Online. A few benefits of using ValidateUpdateListItem are:
Besides Robert's blog, Andrew’s blog also presented detailed info about how to set various types of fields with ValidateUpdateListItem().
My issue was to update Editor and Author fields for a listitem on SharePoint on-premises (SP2016 and SP 2019) without increasing item version.
Both Editor and Author are People and Group (Person) field. According above blogs, you can set the Person field, like:
"[{'Key':'i:0#.f|membership|aaron@contoso.onmicrosoft.com'}]"
This works fine with SharePoint Online users. However, it does not work with SharePoint on-premises users, although no error returned from the method.
After some testing, I found that for SharePoint on-premises users, you need to set the Persons field like below:
"[{'Key':'i:0#.w|aaron@testdomain.com'}]"
The sample below updates the Editor and Author fields on SharePoint on-premises (SP2016 and SP2019) without increasing item version.
{
"formValues": [
{
"__metadata": { "type": "SP.ListItemFormUpdateValue" },
"FieldName": "Editor",
"FieldValue": "[{'Key':'i:0#.w|aaron@testdomain.com'}]"
},
{
"__metadata": { "type": "SP.ListItemFormUpdateValue" },
"FieldName": "Author",
"FieldValue": "[{'Key':'i:0#.w|aaron@testdomain.com'}]"
}
],
"bNewDocumentUpdate": true
}
The REST API ValidateUpdateListItem() on the ListItem object is much easier in providing the Person field values to update. In addition, it has an option bNewDocumentUpdate to specify how you want item version to be updated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.