I have created a Site Collection in SharePoint 2013 online.
In this site I am trying to update Master Page through JavaScript Client Object Model. My JQuery scripts are able to change the Site Master page as well as System Master Page. I can validate the change under Site Settings Master Page (under Look and Feel section).
I am able to execute the script successfully without any error. But when I refresh my home page, it redirects me to error page saying “File Not Found” Error and it gives one correlation ID. When I change any setting in Master Page and save it, my site again looks good.
code which I am using:
//context = new SP.ClientContext.get_current();
//var site = clientContext.get_site();
//var web = context.get_site();
context = new SP.ClientContext.get_current();
var web = context.get_site().get_rootWeb();
context.load(web, 'ServerRelativeUrl');
web.set_customMasterUrl('/_catalogs/masterpage/seattle.master');
web.set_masterUrl('/_catalogs/masterpage/seattle.master');
web.update();
I tried with commented code also for trial... Would appreciate if someone could give me some direction here.....