I get an error after attempting to update an item SharePoint 2013. This one is a bit of a challenge since it's referencing a different file.

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

oListItem.set_item('Role Status', roleStatus); 

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

I get the folllowing error that says "SCRIPT5007: Unable to get property 'apply' of undefined or null reference. File: ScriptResource.axd, Line 5, Column: 298"

Any ideas why?

2 Answers 2


Most likely you reference the wrong function in your executeQueryAsync. Instead of using Function.createDelegate just pass the reference to your functions:

clientContext.executeQueryAsync(onAddSucceeded, onAddFailed);
  • That worked like a charm. Thank you! Any more explanation of why 'Function.createDelegate' did not work?
    – JustMe
    Oct 4, 2018 at 13:54
  • 1
    You referenced this.onAddSucceeded in Function.createDelegate. I bet if you put console.log(this.onAddSucceeded) it will print undefined. In other words, you've tried to set undefined function as your success \ failure handler. Oct 4, 2018 at 14:01
  • Ok. That makes sense. I'm assuming it's also because those function are not part of the 'clientContext' object?
    – JustMe
    Oct 4, 2018 at 14:32
  • 1
    technically they're not part of this. however, I don't know what is this in your application, because you haven't provided full code snippet. Oct 4, 2018 at 14:35

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 code:

oListItem.set_item('Role Status', roleStatus);  // make sure roleStatus is a string

There's already an answer to this issue in the following post Unable to get property 'apply' of undefined or null reference

  • roleStatus is not the problem. It's a variable that grabs different values based on the item selected. It's dynamic, so it works fine. Thanks though.
    – JustMe
    Oct 4, 2018 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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