I have a document library and I would like to update the metadata(columns) of a document using JSOM. I thought the following would work but it works just on custom list.
var ctx = new SP.ClientContext.get_current();
var customLibrary = ctx.get_web().get_lists().getByTitle('Shared Documents');
var listItem = customList.getItemById(itemID);
/*Set the value and update*/
listItem.set_item('Project_0020_Number', prjNum);
listItem.update();
ctx.executeQueryAsync(
function(){
/*Need to change this to show on the page*/
alert('Updated');
},
function(sender, args){ alert('Error: ' + args.get_message()); });
}
function onQueryFailed(sender, args) {
alert('Request failed. '+args.get_message() + '\n' + args.get_stackTrace());