Posts Tagged ‘ECMAScript’
Monday, May 24th, 2010



I had to post this quick article as its one of those can’t see the wood for the trees.

I had been trying to do a simple call back to the server to display some information about a list item.

   getStory: function (id) {
    var backLogList = this.lists.getByTitle('BackLog');
        this.itemToGet = backLogList.getItemById(id);
        context.executeQueryAsync(
        Function.createDelegate(this, com.apps.aberdovey.SprintPlanning.getStorySucceeed),
        Function.createDelegate(this, com.apps.aberdovey.SprintPlanning.onFail));
    },
    getStorySucceed: function (sender, args) {
    alert('got it');
    },

The problem was I never got anything to happen.  My onFail() had an alert and I also showed an alert when the call succeeded.   But nothing.

I reverted to IE Dev toolbar where I kept getting the error

‘b’ is null or not an object

after spending time validating my calling code and cursing the lack of good examples on the web for SharePoint 2010 ECMAScript I eventually found it. 

The delegate name for the getStorySucceed was spelt incorrectly!

It is amazing how much time you spend looking for stupid errors when doing JavaScript development.  This one I thought worth posting so that when other search for ‘b’ is null or not an object they will at least have a better idea what’s wrong.