Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get SP.List property using SharePoint JSOM
function getListProperties(listTitle, OnSuccess,OnError) {
var context = SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle(listTitle);
context.load(web);
context.load(list,'SchemaXml');
context.executeQueryAsync(function(){
var schemaXml = list.get_schemaXml();
var listJson = schemaXml2Json(schemaXml);
OnSuccess(listJson);
},OnError);
}
function schemaXml2Json(schemaXml)
{
var jsonObject = {};
var schemaXmlDoc = $.parseXML(schemaXml);
$(schemaXmlDoc).find('List').each(function() {
$.each(this.attributes, function(i, attr){
jsonObject[attr.name] = attr.value;
});
});
return jsonObject;
}
@ketaanhshah

This comment has been minimized.

Copy link

@ketaanhshah ketaanhshah commented Jun 2, 2015

Do u know how to make this work for Spanish sites where the PAGES library is PAGINAS? this script fails there ...any way to get it working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.