GetItemById in edit form
Posted: 05 Nov 2014
I use a code block like this in a form:
...
var context = new SP.ClientContext.get_current();
var mainList = context.get_web().get_lists().getByTitle('MyList');
var listItem = mainList.getItemById(1);
context.load(listItem);
context.executeQueryAsync( Function.createDelegate(this, function() {
var title = listItem.get_item('Title')
})
);
...
This works perfect in the display form. In the edit form, I get an error saying that the Title field has not been initialized.
I have tried to load the Title field as part of the context.load() with no success. Network trace shows that the data is correct in the response.
Any suggestions how to solve this?
...
var context = new SP.ClientContext.get_current();
var mainList = context.get_web().get_lists().getByTitle('MyList');
var listItem = mainList.getItemById(1);
context.load(listItem);
context.executeQueryAsync( Function.createDelegate(this, function() {
var title = listItem.get_item('Title')
})
);
...
This works perfect in the display form. In the edit form, I get an error saying that the Title field has not been initialized.
I have tried to load the Title field as part of the context.load() with no success. Network trace shows that the data is correct in the response.
Any suggestions how to solve this?