Hi,
I’ve just been looking at a form we designed a while ago for one of our projects, and we originally used the following to update some metadata on documents uploaded to a related items Library:
//Update the relevant metadata for each Document
function updateListItem(itemId, fields, dataTable){
var clientContext = sp.clientcontext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle(‘mydoclibraryname’);
var oListItem = oList.getItemById(itemId);
fields.map(function(item, index) {
oListItem.set_item(item.Field, item.Value);
oListItem.update();
});
clientContext.executeQueryAsync(function(){
console.log(‘Item updated!’);
fd.control(dataTable)._dataProvider.refresh();
}, function(){
console.log(‘Request failed.’);
});
}
I no longer see the sp.js namespace loaded on my form and consequently I get:
Uncaught (in promise) TypeError: Cannot read property ‘get_current’ of undefined
as it would seem I’m not able to load the current context via JSOM (sp.clientcontext).
Has something changed in the recent update that we need to be aware of? I’ve used this function to update metadata in several projects and none of them are working post update.
Kind regards
Andy