Showing posts with label ClientContext. Show all posts
Showing posts with label ClientContext. Show all posts

Tuesday, October 22, 2013

SharePoint 2013 Read Overlay setting using javascript



You can use the following the code to retrieve Calendar Overlay settings using Javascript:

EnsureScriptFunc('sp.js', 'SP.ClientContext', function(){
            var clientContext = new SP.ClientContext.get_current();
            if (clientContext != undefined && clientContext != null) {
                 var web = clientContext.get_web();
                                                                                                                               
                 var listCollection = web.get_lists();
                 var list = listCollection.getByTitle("Calendar");
                 var viewCollection = list.get_views();
                 this.view = viewCollection.getByTitle("Calendar");
                 clientContext.load(this.view);
                 clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),    Function.createDelegate(this, this.onQueryFailed));
}
});
 function onQuerySucceeded() {
        alert(this.view.get_htmlSchemaXml()); //this contains overlays settings
 }
                               
 function onQueryFailed(sender, args) {
       alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
 }