question

Shadow-2170 avatar image
0 Votes"
Shadow-2170 asked MichaelHan-MSFT answered

Modern SP Button to automatically create SitePage using template

In classic SharePoint, we had a custom coded button which would bring up a pop-up (below), take inputs, automatically create a SitePage with the required folders by copying a projects template sitepage, and use that newly created Projects page URL to create a new item within a list of projects.

112039-image.png


This would be the result:
112116-image.png



In the process of making a modern SP Homepage, I can add a button and link it to the default New Project button within the List which brings up the following options:

112159-image.png


The previous button automatically did the steps of creating a new site page and filling in the Projects URL section of this. My question is:

How can I create a button to automate a task such as creating a new SitePage from a template, and use that URL to create a new List item in Modern SharePoint?
Previously this was done in a very complicated and convoluted way using SharePoint designer and I don't want to replicate that.
- Can I use some REST API Calls or PowerShell scripts?
- If so, or any other such method, how would those be linked to a button on the Sharepoint Homepage itself?





office-sharepoint-onlinesharepoint-dev
image.png (11.9 KiB)
image.png (21.1 KiB)
image.png (46.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered

Hi @Shadow-2170,

As a workaround, you could create a Power Automate/flow to automate the task(create a new SitePage from a template, and use that URL to create a new List item).

In the flow, you could use REST API Calls to create a sitepage by copying a template sitepage.

Then you could link the flow page to the button on SharePoint page.


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.