Right now I am using this method:
function getWebProperties(id) { var ctx = new SP.ClientContext.get_current(); this.website = ctx.get_web(); this.listCollection = website.get_lists(); this.oList = listCollection.getByTitle('NavStructure'); this.oItem = oList.getItemById(id); ctx.load(oItem, 'Include(Id, DisplayName)'); ctx.executeQueryAsync(Function.createDelegate(this, this.onSuccess), Function.createDelegate(this, this.onFail)); } function onSuccess(sender, args) { alert("Title: " + oItem.get_displayName() + " ID: " + oItem.get_id()); } function onFail(sender, args) { alert('failed to get list. Error:' + args.get_message()); } But it keeps erroring out (through the onFail method) with:
failed to get list. Error:Invalid request
I also changed this line:
ctx.load(oItem, 'Include(Id, DisplayName)'); to
ctx.load(oItem); And it errored out (in the browser. never fired the onFail method) with:
uncaught exception: [Exception... "'Error: The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "JS frame :: resource://firebug_rjs/net/spy.js :: callPageHandler :: line 796" data: no]
Can anyone see what I am doing wrong here?