pnp / PnP-Provisioning-Schema

Office 365 Patterns and Practices - Remote Provisioning Schema
MIT License
159 stars 220 forks source link

Support for Modern Document Library "Edit New Menu" Options #558

Closed anthonywhite closed 2 years ago

anthonywhite commented 3 years ago

Please consider supporting the Modern Document Library "Edit New Menu" Options in PnP templates. Thanks

patrikhellgren commented 2 years ago

@anthonywhite In recent nightly versions of PnP.Framework (used in PnP.PowerShell and should be available at least since the first release in november) it is possible to configure the New button options, at least if you configure the template manually. Here is an example of how to disable the "New folder" and the "Standard document" content type entries and then adding a Word, Excel and PowerPoint template using the "Standard document" content type. Of course you need to copy the templates in place using the template also. You then just add the NewDocumentTemplates element to the view. This contains a json array with the different entries. I usually use SharePoint Online Client Browser to extract a view that I already configured in the UI and then manually replace content type id and site url with provisioning tokens like you see in the example.

<View Name="{E6F40AE8-D8BE-467A-8990-A0CC2DC750CB}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="All documents" Url="{site}/Shared%20Documents/Forms/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/dlicon.png?rev=47">
    <Query>
        <OrderBy>
            <FieldRef Name="FileLeafRef" />
        </OrderBy>
    </Query>
    <ViewFields>
        <FieldRef Name="DocIcon" />
        <FieldRef Name="LinkFilename" />
        <FieldRef Name="Modified" />
        <FieldRef Name="Editor" />
    </ViewFields>
    <RowLimit Paged="TRUE">30</RowLimit>
    <JSLink>clienttemplates.js</JSLink>
    <CustomFormatter />
    <NewDocumentTemplates>[{"templateId":"NewFolder","title":"Folder","visible":false},{"contentTypeId":"{listcontenttypeid:Documents,0x010100374A5AF4E0834C5D8EE82A952575034801}","isContentType":true,"templateId":"{listcontenttypeid:Documents,0x010100374A5AF4E0834C5D8EE82A952575034801}","title":"Standard document","visible":false},{"templateId":"NewDOC","title":"Word-dokument","visible":false},{"templateId":"NewXSL","title":"Excel-arbetsbok","visible":false},{"templateId":"NewPPT","title":"PowerPoint-presentation","visible":false},{"templateId":"NewONE","title":"OneNote-anteckningsbok","visible":false},{"templateId":"NewXSLSurvey","title":"Excel-undersökning","visible":false},{"templateId":"NewXSLForm","title":"Forms för Excel","visible":false},{"templateId":"NewVSDX","title":"Visio-ritning","visible":false},{"contentTypeId":"{listcontenttypeid:Documents,0x010100374A5AF4E0834C5D8EE82A952575034801}","isUpload":true,"templateId":"Excel Workbook","title":"Excel Workbook","url":"{site}/Shared%20Documents/Forms/Excel Workbook.xlsx","visible":true},{"contentTypeId":"{listcontenttypeid:Documents,0x010100374A5AF4E0834C5D8EE82A952575034801}","isUpload":true,"templateId":"PowerPoint Presentation","title":"PowerPoint Presentation","url":"{site}/Shared%20Documents/Forms/PowerPoint Presentation.pptx","visible":true},{"contentTypeId":"{listcontenttypeid:Documents,0x010100374A5AF4E0834C5D8EE82A952575034801}","isUpload":true,"templateId":"Word Document","title":"Word Document","url":"{site}/Shared%20Documents/Forms/Word Document.docx","visible":true}]</NewDocumentTemplates>
</View>
anthonywhite commented 2 years ago

Hi @patrikhellgren, many thanks for the update and example.