web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Flow in SharePoint to ...
Power Automate
Suggested Answer

Flow in SharePoint to handle three different elements

(3) ShareShare
ReportReport
Posted on by 44
This group has been invaluable to me in the past, better than Co-Pilot could ever be. (I've spend days with Co-pilot trying to get this done, and it gets keep sending me in circles).

Here's my hair pulling scenario.

I have my SharePoint standard Document library.
It has a custom content type called Link to site (Derived from the Link to Document).

I need a flow that does the following:

1) When a folder, with files and subfolders is uploaded, everything is completely deleted (note:  Unable to add a script to the environment to disable uploading folders)
2) In the same document library, when a Link to Site is used, the NAME of the link is copied to the TITLE Field
3) when a Document is uploaded/or modified, a set of concatenations occur and they populate a COMBINED (text field).  The Value of the Combined fields, then is used to rename the file name while leaving the file extension as it is.

I have tried more than a dozen standard flows with conditions, none work.  I have tried to use a SWITCH, it doesn't work.

I am beyond frustrated.

I know that I can have multiple workflows running, but each would trigger each and every time activity is detected in the document library, so performance becomes a serious issue.
Categories:
I have the same question (0)
  • Suggested answer
    Haque Profile Picture
    3,653 on at
    Hi@CU08031624-0,
     
    The use can be achieved using three separate flows or a parent child flow. Let's see how independent flow can be applied first:
     
    Delete Uploaded Folder with All Contents (Flow-1)

    Since you cannot disable folder uploads directly(using script), create a flow triggered when a folder is created in the document library:

    • Trigger: "When an item is created (properties only)"  or "When an item is created"in the document library.

    • Condition: Check if the created item is a folder (IsFolder property). Here: Add a Condition action after the trigger. In the condition, select the dynamic content field named IsFolder (sometimes shown as IsFolder or Folder depending on the connector). Set the condition to check if "IsFolder is equal to true".

    • Action:

      • Use "Get files (properties only)" filtered by the folder path to list all files and subfolders inside.

    [Set relevent parameters here: Include Nested Items = true (so it will include all files, subfolders and files in sub folders.]
    • you can add a Filter Array action to separate files and folders [For Files: item()?['FSObjType'] equals 0 and for Folders: item()?['FSObjType'] equals 1]

    • Loop through and delete all files: Add an "Apply to each" loop on the output of the "Get files" action. Inside the loop, add a "Delete file" action.For the "Delete file" action, use the file identifier or file path from the current item in the loop.

    • Loop through and delete all subfolders.

    • Finally, delete the folder itself.

    For deleting files and folders: Please see this video and also this

     

    Copy Link Name to Title Field for "Link to Site" Content Type(Flow-2)

    Create a flow triggered when an item is created or modified in the document library:

    • Trigger: When an item is created or modified.

    • Condition: Check if the content type equals "Link to Site". Add a Condition action after the trigger. In the condition, select the dynamic content field named Content Type (sometimes shown as ContentType or ContentTypeName depending on the connector).Set the condition to check if the content type equals the exact name of your custom content type, e.g., "Link to Site". Please  note that Condition: Content Type is equal to Link to Site

    • Action:

      • Get the value of the link's name (usually the Name or FileLeafRef field).
      • Update the same item’s Title field with this link name.

     

    Concatenate fields into a COMBINED text field (Flow-3)

    1. Trigger: When a file is created or modified in the SharePoint document library.
    2. Get item properties: Retrieve the metadata of the uploaded or modified document, including the fields you want to concatenate.
    3. Concatenate fields: Use a Compose or Set Variable action to concatenate the desired fields into a single string for the COMBINED field.
    4. Update the COMBINED field: Update the SharePoint item’s COMBINED text field with the concatenated string.
    5. Rename the file
    • Extract the file extension from the current file name.
    • Build the new file name by combining the concatenated string and the original file extension.
    • Use the "Send an HTTP request to SharePoint" action or "Move file" action to rename the file by moving it to the same folder with the new name. 

    If you want things modular and cleaner.
    Parent Flow: 
    Trigger: When an item is created or modified in the document library. 

    Actions:

    • Check if the item is a folder, a "Link to Site" content type, or a document.
    • Call the appropriate child flow passing necessary parameters:
      • Child Flow 1: Folder deletion logic.
      • Child Flow 2: Link to Site name-to-title sync.
      • Child Flow 3: Document concatenation and rename.

    Child Flows

    • Child Flow 1: Deletes folder contents (including files) and the folder itself.
    • Child Flow 2: Copies the link name to the Title field for "Link to Site" items.
    • Child Flow 3: Concatenates fields, updates the COMBINED field, and renames the document file.

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!

     

  • Suggested answer
    11manish Profile Picture
    3,333 on at
    What you were trying to build is essentially:
    “a mini document management system inside SharePoint”
    That requires:
    • separation of event concerns
    • idempotent flows (no repeated execution side effects)
    • metadata-driven processing (flags)
    Trying to force it into one flow is exactly why Co-Pilot kept looping you.
  • Suggested answer
    Valantis Profile Picture
    6,735 on at
     
    You are right to want one flow. Multiple flows all triggering on the same library is worse for performance than one flow with branching logic. Here is the architecture and the specific fix for each scenario.
     
    Trigger: "When a file is created or modified (properties only)" on the library (no folder filter, covers the whole library).
    Then use a Condition or Switch on the content type to branch into three paths.
     
    Path 1 - Folder uploaded
    Check: isFolder is equal to true
    To delete a folder with all its contents, you cannot use the standard Delete file action. Use "Send an HTTP request to SharePoint" instead:
    - Method: DELETE
    - Uri: _api/web/GetFolderByServerRelativeUrl('/sites/YourSite/Shared Documents/@{triggerOutputs()?['body/{FilenameWithExtension}']}')
    This deletes the folder and all its nested files and subfolders in one call.
     
    Path 2 - Link to Site
    Check: ContentTypeId starts with the ContentTypeId of your Link to Site content type (get it from the library settings URL)
    Action: Update file properties
    - FileLeafRef (Name) copied to Title column
     
    Path 3 - Document
    Check: isFolder is equal to false AND ContentTypeId does not start with your Link to Site type ID
    Action 1: Build your concatenated COMBINED value using a Compose action
    Action 2: Update file properties to set the COMBINED field
    Action 3: To rename the file, use "Move file" action - same site, same library, same folder path, but change the filename to the COMBINED value while preserving the extension using:
    last(split(triggerOutputs()?['body/{FilenameWithExtension}'], '.'))
    to extract the extension, then append it to your COMBINED value.
     
    One important note on the folder detection: when a user uploads a folder, SharePoint creates the folder item AND then each file inside it as separate events. The isFolder check on the first event (the folder itself) is what you catch to delete it. The child files may also trigger the flow briefly before the folder is gone. Add a short Delay (5-10 seconds) before the delete to give SharePoint time to finish creating the whole structure, then delete the parent folder in one HTTP call rather than trying to loop through children.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

  • Valantis Profile Picture
    6,735 on at

    Hi @CU08031624-0,

    Just wanted to check in and see if everything is working now. If you still need any help, feel free to let me know.

    Also, if the issue is resolved, it would be great if you could mark the answer as solved so others with the same question can find it easily.

     

    Thanks and have a great day!

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard