1

I'm creating a Power Automate flow with which among other things I would like to set the default page template in a newly created site.

I have the whole site creation part done, as well as retrieving the id of the template to use, but I can't figure out how to set the default page template.

I know it is done through the 'DefaultNewPageTemplateId' option, which I can see in the 'AllProperties' of a site, but how can I actually set it?

This is more or less a follow-up question to Set default page template on Communication site with PowerShell

1 Answer 1

1

Previously I have done it using below SharePoint REST API endpoint and payload with JavaScript:

<button type="button" onclick="SetDefaultPageTemplate()"> Set Default Page Template</button>

<script type="text/javascript" src="/sites/SPConnect/SiteAssets/jquery.min.js"></script>
<script type="text/javascript">
    function SetDefaultPageTemplate() {
        var webEndpoint = _spPageContextInfo.webAbsoluteUrl + "/_api/web";

        //Visual template: ac3c4a88-04f2-4e54-a411-df9899c90df5
        var webProperties = {
            '__metadata': { 'type': 'SP.Web' },
            'DefaultNewPageTemplateId': 'ac3c4a88-04f2-4e54-a411-df9899c90df5'
        }

        $.ajax({
            url: webEndpoint,
            type: "POST",
            headers: {
                "accept": "application/json;odata=verbose",
                "content-type": "application/json;odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                "X-HTTP-Method": "MERGE",
                "If-Match": "*"
            },
            data: JSON.stringify(webProperties),
            success: function(data) {
                console.log(data);
            },
            error: function(error) {
                console.log(error);
            }
        });
    }
</script>

Try using REST API endpoint URL and payload like above in your Power automate flow and see if it works for you.

Related Read:

  1. Set a page template as default page template in SharePoint Online

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.