Forum Discussion

automan25's avatar
automan25
Copper Contributor
May 22, 2024

Document Sets - Default Content

Is there a way to designate a specific filename when a user adds default content item to a document set? For example, I have a letter template set up as a piece of default content available to my ...
  • NikolinoDE's avatar
    May 23, 2024

    automan25 

    In SharePoint Online, while there is no direct out-of-the-box setting to automatically rename the default content when adding it to a Document Set, so far i know :smile:.

    But you can maybe try to achieve this using Power Automate.

    Im not sure, if this works. Here a try:

    Step-by-Step Solution:

    1. Set Up Document Set with Default Content:
      • Ensure you have your Document Set content type configured and the default content added (e.g., Letter Template).
    2. Create a Power Automate Flow:
      • Trigger: Use the "When a file is created or modified (properties only)" trigger from SharePoint.
      • Condition: Check if the file is inside the desired Document Set and if the file name matches document.docx.
      • Action: Rename the file to the desired template name.

    Detailed Steps to Create the Flow:

    1. Go to Power Automate:
    2. Create a New Flow:
      • Click on "Create" and select "Automated flow".
    3. Set the Trigger:
      • Choose "When a file is created or modified (properties only)".
      • Set the Site Address and Library Name to point to your SharePoint Document Library.
    4. Add a Condition:
      • Click on "New step" and add a "Condition".
      • Set the condition to check if the file name is document.docx.
        • In the "Choose a value" box, select the "File name with extension" dynamic content.
        • Choose "is equal to" as the operator.
        • Enter document.docx in the value box.
    5. Add Actions for the Condition:
      • If the condition is true (i.e., the file name is document.docx):
        • Add a "Send an HTTP request to SharePoint" action.
        • Configure it to rename the file.
          • Site Address: Your SharePoint site address.
          • Method: POST.
          • URI: _api/web/GetFileByServerRelativeUrl('<library-relative-url>/document.docx')/moveto(newurl='<library-relative-url>/LetterTemplate.docx',flags=1).
          • Headers:
            • Key: Accept
            • Value: application/json;odata=verbose
    6. Save and Test the Flow:
      • Save your flow and test it by creating a new document in the Document Set.
      • The flow should trigger and rename the document.docx file to LetterTemplate.docx.

    Example Power Automate Flow Configuration:

    Trigger: When a file is created or modified (properties only)

    • Site Address: Your SharePoint site URL.
    • Library Name: Your document library name.

    Condition:

    • Condition: File name with extension is equal to document.docx.

    If Yes:

    • Action: Send an HTTP request to SharePoint
      • Site Address: Your SharePoint site URL.
      • Method: POST
      • URI: _api/web/GetFileByServerRelativeUrl('/sites/yoursite/Shared Documents/document.docx')/moveto(newurl='/sites/yoursite/Shared Documents/LetterTemplate.docx',flags=1)
      • Headers:
        • Accept: application/json;odata=verbose

    Notes:

    • Make sure to replace placeholders like <library-relative-url>, yoursite, Shared Documents, etc., with actual values from your SharePoint setup.
    • Ensure you have proper permissions to use the "Send an HTTP request to SharePoint" action, as it requires elevated permissions.

    By setting up this flow, you can automate the renaming process, making it easier for users to manage and identify documents within the Document Set. The text and the steps were created with the help of AI.

     

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

     

    Was the answer useful? Mark as best response and like it!

    This will help all forum participants.

Resources