Hello everyone,
For my customer I need to implement a one click solution to build a SharePoint sub web and setup the security around it.
I decided not to use a SharePoint hosted app since it requires Site collection full control which I don't want to give to the user running this solution
I decided not to use a SharePoint provider app because of the infrastructural complexity behind that my client does not want to implement.
So I decided to go for a JSOM solution that is called through a Content Editor WebPart dropped on a page that renders the form and allows site creation with Web Full Control only instead of Site collection Full Control. (this is acceptable)
I managed to create the sub web, enable the publishing feature and create all the groups required by my solution, but I need to create a publishing page (the home page actually) but I encounter a stupid error that I don't understand. Here is the code I use:
var clientContext = new SP.ClientContext(siteNameAndUrl);
var web = clientContext.get_web();
var pubWeb = SP.Publishing.PublishingWeb.getPublishingWeb(clientContext, web);
clientContext.load(web);
clientContext.load(pubWeb);
clientContext.executeQueryAsync(function(){
alert('OK');
},handleError);
When this code reaches the clientContext.load(pubWeb) I get the following error:
Object doesn't support property or method 'get_$y_0'
Does any of you have a clue of what is going on and why I get this error?
Thanks in advance!