10 thoughts on “Modern Page Provisioning in the SharePoint Framework (SPFx)”
Hi, how about adding a new page using the template created by me using a SharePointFullPage webpart? I dont want my customers to have to create them from native UI…
Hi, but when we specify the parameter for the template (in your case “Article”), is it possible to use a template created by me and deployed as a SharePointFullPage webpart?
I was able to do that by using this:
await sp.web.addClientsidePage(url, title, “SingleWebPartAppPage”).then(async page => {
let sec = page.addSection();
sec.addColumn(12);
await sp.web.getClientsideWebParts().then(partDefs => {
const partDef = partDefs.filter(c => c.Id.replace(“{“,””).replace(“}”,””).toLowerCase() === templateId);
if (partDef.length < 1) {
throw new Error("Could not find the web part");
} else {
const part = ClientsideWebpart.fromComponentDef(partDef[0]);
sec.addControl(part);
}
});
You can this for create new page
const page = await sp.web.addClientSidePageByPath(`file-name`, “/sites/dev/SitePages”);
use this for edit existing page
const page = await ClientSidePage.fromFile(sp.web.getFileByServerRelativeUrl(“/sites/dev/SitePages/ExistingFile.aspx”));
Hi, how about adding a new page using the template created by me using a SharePointFullPage webpart? I dont want my customers to have to create them from native UI…
LikeLiked by 1 person
If you want to avoid native UI then you need to build Custom SPFx webpart
LikeLiked by 1 person
Hi, but when we specify the parameter for the template (in your case “Article”), is it possible to use a template created by me and deployed as a SharePointFullPage webpart?
LikeLiked by 1 person
Hi Bruno,
When I tried the same I got error, But instead of using template if you use page as template all works perfect.
LikeLiked by 1 person
I was able to do that by using this:
await sp.web.addClientsidePage(url, title, “SingleWebPartAppPage”).then(async page => {
let sec = page.addSection();
sec.addColumn(12);
await sp.web.getClientsideWebParts().then(partDefs => {
const partDef = partDefs.filter(c => c.Id.replace(“{“,””).replace(“}”,””).toLowerCase() === templateId);
if (partDef.length < 1) {
throw new Error("Could not find the web part");
} else {
const part = ClientsideWebpart.fromComponentDef(partDef[0]);
sec.addControl(part);
}
});
await page.save(false);
});
LikeLiked by 1 person
How can we create a page with in the folders?
LikeLike
Hi Abish,
You can this for create new page
const page = await sp.web.addClientSidePageByPath(`file-name`, “/sites/dev/SitePages”);
use this for edit existing page
const page = await ClientSidePage.fromFile(sp.web.getFileByServerRelativeUrl(“/sites/dev/SitePages/ExistingFile.aspx”));
LikeLike
addClientSidePageByPath method is not supporting for v2.4.0. My current version is 2.4.0. What should i do now?
LikeLike
Hi Sir,
I have created the page with file viewer web part. All file format is working fine. But excel and csv file is not loading. Please help me out.
LikeLike
Sorry, I don’t any idea. for me works fine
LikeLike