I'm on SP2013 in an O365 environment.

I am trying to pull some data from a list and render that data using the Google charts API. I am doing this in a content editor web part that points to an HTML page in the site's Site Assets library.

Using the following JavaScript, I get the 'Unable to get property 'get current' of undefined or null reference' error in the debugger.

function getItem(listTitle,itemId,success,error){  
     var context = SP.ClientContext.get_current();
     var web = context.get_web();
     var list = web.get_lists().getByTitle(listTitle);
     var listItem = list.getItemById(itemId);

        function() {

  var dxOrphan = getItem('ChartData', 1,
        var result = item.get_item('Topics');

The reading I've done seems to indicate that this is a problem with sp.js loading after the getItem() function is called.

So I added the following line:

ExecuteOrDelayUntilScriptLoaded(getItem, "sp.js");

Which gets me a new error, this time in sp.js: "Unable to get property 'toUpperCase' of undefined or null reference."

I'm guessing that this is because the getItem () function is returning no data, but it's odd, because sp.js still seems to be loading afterwards -- that is, I always get the 'get current' error first, then the 'toUpperCase' error.

I feel like I'm close to getting this working, and have been Googling furiously for the past few hours trying to find a solution. If I should scrap this approach and try something else, I'm happy to hear that message as well.

  • Have you seen my answer, was it helpful? Oct 9 '14 at 18:14
  • I have, yes, and it's very helpful! I got pulled into something else and haven't had an opportunity to try it out yet. Hope to get some time this afternoon. Oct 9 '14 at 18:17

As a part of the new Minimal Download Strategy (MDS) the sp.js library is not loaded until explicitly called in SharePoint 2013.


Use SP.SOD.executeFunc function to ensure that sp.js library is loaded and then run the specified callback function:

SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function(){

   //Your code goes here, for example


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.