128
rated 0 times
[
130]
[
2]
/ answers: 1 / hits: 26373
/ 10 Years ago, mon, july 21, 2014, 12:00:00
I am trying to access the ID of Library using client-side object model in SharePoint 2013. But I am getting error as:
The property or field 'Id' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
Below is my code:
var context = SP.ClientContext.get_current();
var web = context.get_web();
var items = SP.ListOperation.Selection.getSelectedItems(context);
var currentLibrary = web.get_lists().getById(SP.ListOperation.Selection.getSelectedList(context));
context.load(currentLibrary, 'id'); // Tried with 'Id' but still throws error
console.log(currentLibrary);
console.log(currentLibrary.get_id = + currentLibrary.get_id()); // THROWS ERROR!
What am I doing wrong here?
More From » sharepoint