Forum Discussion
dzorzi
Jul 05, 2022Copper Contributor
CSOM SystemUpdate() cannot update Editor field
In a SharePoint Online Document Library I've a file that is in published status (version x.0). I am updating various fields of this file with the listItem.SystemUpdate() command. I need this sort o...
FabioO365GoD
Jul 06, 2022Copper Contributor
dzorzi
Hi, you should use
SP.FieldUserValue.fromUser('i:0#.f|membership|email address removed for privacy reasons')
you have to get the LoginName from the user
Example
var context = SP.ClientContext.get_current();
var list = context.get_web().get_lists().getByTitle(listTitle);
var itemCreateInfo = new SP.ListItemCreationInformation();
var listItem = list.addItem(itemCreateInfo);
listItem.set_item("Title", "Item Test User");
listItem.set_item("Author", SP.FieldUserValue.fromUser("i:0#.f|membership|email address removed for privacy reasons"));
listItem.update();
context.executeQueryAsync(
function () {
console.log("Request has been created");
},
function logError(sender, args) {
console.log(args.get_message());
}
);
Thanks