I am using JSOM to update an item in a list, which I've had no problem with in the past. But for some odd reason I'm getting an error that I'm not sure about. Maybe I'm overlooking something small. see below

 var siteUrl = _spPageContextInfo.webAbsoluteUrl
 var clientContext = new SP.ClientContext(siteUrl);
 var oList = clientContext.get_web().get_lists().getByTitle('Document Approval');
 this.oListItem = oList.getItemById(promise.responseJSON.d.results[0].ID);

 oListItem.set_item('Role Status', roleStatus); //<-- Error Here

     Function.createDelegate(this, this.onAddSucceeded),
     Function.createDelegate(this, this.onAddFailed)

Here's the error I get 'oListItem' is undefined

Thanks for any help you can provide.


You have not defined oListItem.

Declare oListItem as a variable.

i.e. var oListItem = oList.addItem(itemCreateInfo);

Edit: For update list item

As compared from the Microsoft Document

oListItem.set_item('Title', 'My Updated Title'); // both the parameters of set_item function accepts string where the first string parameter denotes the field name and the second string parameter denotes the value of the item to be set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.