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);
},
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);
},
Thank you for sharing wonderful information with us to get some idea about that content.
ReplyDeleteOffice 365 Training
Office 365 Online Training