Last active
August 29, 2015 14:08
-
-
Save vgrem/5734768696c5f0119085 to your computer and use it in GitHub Desktop.
Get SP.List property using SharePoint JSOM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
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?