Edit New menu on SharePoint library

Milan Ostojić 0 Reputation points
2023-08-21T09:57:33.9233333+00:00

Hi,

I am applying some pnp provisioning template for Document library on SharePoint sites. Here also set some custom content types.
What in case we want to apply these custom content types and keep all default offices types (Word, Excel, PowerPoint, Visio etc...) while applying provisioning template to Document library ?

In my case I want to add custom content type of 'Document' (opens local word document). But when I apply that template to library, other offices types not visible by default anymore and need manually to check it for each site through Edit New menu. Is there anyhow I can detect ContentTypeId of those offices types, so I can include it in template as custom content types in tags pnp:ContentTypeBindings</pnp:ContentTypeBindings>
like I do for other custom content types.

Additional question =>
When select to open Document (my custom type) it will open me word locally. Is there any way to set default save location for that opened word file automatically (through open link or else) ? Currently save location points to OneDrive, if user has it locally, otherwise it is SharePoint site which is wanted behavior.

Microsoft 365 and Office | SharePoint | Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-08-22T07:03:10.07+00:00

    Hi @Milan Ostojić

    Please achieve your goal by following steps:

    First, you need to find the content type ID for the default Office type. You can get them by going to Site Settings > Site Content Type Gallery and selecting the content type you want.

    In your browser's address bar, you'll see a URL similar to https://yoursharepointsite/_layouts/15/ManageContentType.aspx?ctype=0x0101, where 0x0101 is the content type ID.

    Second, you need to add the pnp:ContentTypeBindings tag to your pnp settings template and specify the IDs of the content types you want to apply to the document library. For example, if you want to add two content types "Document" and "Word Document", you can use the following code:

    <pnp:ContentTypeBindings>
       <pnp:ContentTypeBinding ContentTypeID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D" Defa ult="true" />
       <pnp:ContentTypeBinding ContentTypeID="0x0101" />
    </pnp:ContentTypeBindings>
    

    Finally, you need to apply your pnp setup template to the document library. You can use PnP PowerShell commands to do this. For example, if your template file is called "template.xml", you can use the following command:

    Apply-PnPProvisioningTemplate -Path template.xml -ResourceFolder "resources"
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.

    Best Regards

    Cheng Feng


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.