Skip to content

Instantly share code, notes, and snippets.

@vgrem
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vgrem/5734768696c5f0119085 to your computer and use it in GitHub Desktop.
Save vgrem/5734768696c5f0119085 to your computer and use it in GitHub Desktop.
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;
}
@DeepMalh44
Copy link

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