In a sharepoint 2013 Blog site I am posting a post on behalf of few senior members of our organization. As usual it shows my name in posted by field. Is there a way to change that programatically change the AuthorId.
I had tried the following code
<script src="/apps/test/Style%20Library/css%20files/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="/apps/test/Style%20Library/css%20files/jquery.SPServices-2013.02a.js" type="text/javascript"></script>
<script type="text/javascript">
var siteUrl = '/apps/test/blog';
function updateListItem() {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('Posts');
this.oListItem = oList.getItemById(5);
oListItem.set_item('AuthorId', '22');
oListItem.update();
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
alert('Item updated!');
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
When I execute the above code it says,
Request failed. Column 'AuthorId' does not exist. It may have been deleted by another user. /apps/opus/blog/Lists/Posts undefined
But When I read the same list using similar JS code I am able see AuthorId. Please suggest a way to update/change AuthorId for a post.