You can use the JavaScript Client object model. Assuming the window _spPageContextInfo
object is set with the initialized properties webServerRelativeUrl
, pageListId
and pageItemId
:
var context = new SP.ClientContext(_spPageContextInfo.webServerRelativeUrl); var list = context.get_web().get_lists().getById(_spPageContextInfo.pageListId); var item = list.getItemById(_spPageContextInfo.pageItemId);
Then you can load the required fields:
context.load(item, "Title", "Location"); context.executeQueryAsync(Function.createDelegate(this, this.mySuccessFunction), Function.createDelegate(this, this.myErrorFunction));
item
will now be filled in with the fields you requested, and you can get them like this:
var itemTitle = item.get_item("Title"); var itemLocation = item.get_item("Location");
Note that you must use the display, not internal, names of the fields you want to load.
source share