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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
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?