For the past days I've been trying, with no success, to establish a connection to a sharepoint list (https://mywebsite.com/sites/concasbkcu/Lists/list_teste/AllItems.aspx) and update its items with the follow code:
var siteUrl= 'https://mywebsite.com/sites/concasbkcu/';
var targetlistItem;
var itemID = 1;
function updateListItem() {
var clientContext = new SP.ClientContext(siteUrl);
var targetList = clientContext.get_web().get_lists().getByTitle('list_teste');
targetListItem = targetList.getItemById(itemID);
targetList.set_item('Title', 'Test Title');
targetList.update();
clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
}
function onQuerySucceeded() {
alert('Item updated!');
}
function onQueryFailed() {
alert('Request failed');
}
I tried calling this function on a html button, but it just doesn't work...no error message is shown and the item doesn't update at all. Can someone help me, please?
Regards!