Modern Page Provisioning in the SharePoint Framework (SPFx)

πŸš€ This article has moved!

Please visit the updated version here:

πŸ‘‰ Go to Updated Article

10 thoughts on “Modern Page Provisioning in the SharePoint Framework (SPFx)

  1. 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…

    Liked by 1 person

  2. 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);
    });

    Liked by 1 person

    • 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”));

      Like

  3. addClientSidePageByPath method is not supporting for v2.4.0. My current version is 2.4.0. What should i do now?

    Like

  4. 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.

    Like

Comments