Hi,
In this article we will see how to provision SharePoint site using PnP JS and more we can provision by our own custom site template. For this we need to know the GUID of your custom template, there are various way to get GUID of site template and one of the easy way is shown below,
I just moved to the page where we can manually create subsite (https://<sharepointURL>/_layouts/15/newsbweb.aspx ). Right click on the custom template name and select Inspect from your browser so that you can see the source of the page and from that we can get GUID of your custom template.
Once we get the template ID, we need to call below PnP code to provison site and in the parameter we need to provide values for following options –
Site Title, URL, description, template name or ID, lang, permission Inheritance.
import pnp from "sp-pnp-js/lib/pnp";
pnp.sp.web.webs
.add(
"New Sub Site",
"newsite",
"Description for the new Site",
"{1BDB855A-CC85-4AF4-8C58-BCDD7F02xxxx}",
1033,
true
)
.then(function(result) {
if (result.data.Created) {
alert("Site created successfully");
}
})
.catch(e => {
console.log("eeerrr", e);
});
Happy Coding
Ahamed
Leave a comment