If somebody like the post and its helpful in your work then, add comments.

Monday, March 2, 2015

Office 365 : Create a site using custom site template

To create a site using your designed custom site template in JSOM/ECMA, we can use below example :

 createProjectSite = function ($data) {
            dialogValue = SP.UI.ModalDialog.showWaitScreenWithNoClose("Site Creation", "Working on it...", 120, 400);
            id($data.Id);
            var url = $data.Title.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
            currentProjectObject = $data;
            var clientContext = CORO.megaMenucontext;
   


            var WCI = new SP.WebCreationInformation();
            WCI.set_webTemplate('{a5269682-aec6-49d7-b3f5-7481039abff8}#ProjectTemplate');
            WCI.set_description($data.ProjectDescription);
            WCI.set_title($data.Title);
            WCI.set_url(url);
            WCI.set_language('1033');
            if ($data.Access == "Public") { WCI.set_useSamePermissionsAsParentSite(true); }//To inherit the permission
            if ($data.Access == "Closed") { WCI.set_useSamePermissionsAsParentSite(false); }//To break the permission
            newWeb = projectWeb.get_webs().add(WCI);
            //save changes and generate callbacks
            clientContext.load(projectWeb);
            clientContext.executeQueryAsync(onCreationSuccess, onQueryFailed);
        },

No comments:

Post a Comment