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 / Trigger Condition when...
Power Automate
Unanswered

Trigger Condition when a file is uploaded inside a specific folder and get the main folder ID

(0) ShareShare
ReportReport
Posted on by 3,514

I have a SharePoint online site which contain a document library named "Customer Share" >> and inside this library we have a folder named "Clients" >> and inside the "Clients" folder we have around 10,000 sub-folders representing clients.

 

Here is a sample of the folder structure:-

 

- Customer share

  - Clients

       - ClientA

            - Contracts

            - Agrements

            - others

       - ClientB

            - Contracts

            - others

       - ClientC

       - ClientD

 -  Attachments

 -  others

 

Now i want to define a trigger condition when a document is created or modified ONLY under the "Clients" fodler's sub-folders. for example to trigger the flow if someone add a file under "Clients/ClientA/Contracts" or under "Clients/ClientA/" or under "/Clients/ClientA/Contracts/2023/".. while the flow should not run if someone add or modify a file under "/Attachments/" or "others" or directly under "/Clients" .. is this possible?

 

Second Point. i also need to get the folder Id of the related client sub-folder. for example if a file is uploaded inside "/Clients/ClientA/Contracts/2023/" i want to get the ID of the ClientA folder..

Thanks

Categories:
I have the same question (0)
  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @johnjohn123 

    Try this as your trigger filter:

    greater(length(split(triggerOutputs()?['body/{Path}'],'/')),2)

     

    If the length of the array resulting from splitting the path on a / is greater than 2, you are in a subfolder

     

    Likewise, you can use a SharePoint Get folder metadata using path action to get the upper level folder ID.

    You will need to supply the path.  You can build the path from the result of a split:

    split(triggerOutputs()?['body/{Path}'],'/')

    You can refence the individual elements to build the path to an upper level folder. 

    image.png

     

    Let me know if you need more help.

  • johnjohn123 Profile Picture
    3,514 on at

    @ScottShearer thanks will try this any update you accordingly.. Thanks

  • johnjohn123 Profile Picture
    3,514 on at

    @ScottShearer but how i can differentiate if the file is been uploaded to these folders "/Attachments/" or "others" or directly under "/Clients" ?? you appraoch assume that there is only one folder named Clients.. am i correct? while we have folders with the same level as Clients named Attachments & Others and so on..

  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @johnjohn123

    OK - so how about checking for /clients/ in the path?

    I am assuming there is only one directory called clients and you are interested in anything blow that.

    Something like this:

    greaterOrEquals(indexOf('/Clients/',[Reference to the path from Dynamic props]),0)

    If /Clients/ is not in the path, indexOf will return -1

     

     

     

  • johnjohn123 Profile Picture
    3,514 on at

    @ScottShearer thanks for the reply, so i will need to merge the 2 condition together ? am i correct?

  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @johnjohn123 

    An expression like greaterOrEquals(indexOf('/Clients/',[Reference to the path from Dynamic props]),0) is all you need for your trigger filter.

    You can use the split() example in my screen shot above when retrieving the folder metadata.

    Give it a try and post screen shots if you need more help.

     

  • johnjohn123 Profile Picture
    3,514 on at

    @ScottShearer  ok will try them both and keep you posted. Thanks

  • johnjohn123 Profile Picture
    3,514 on at

    @ScottShearer unfortunately when i added the 3 trigger conditions together ,, the flow will never run.. i created a new question @ https://powerusers.microsoft.com/t5/Building-Flows/quot-When-a-file-is-created-or-modified-property-only-quot-with/m-p/2242909#M248870  if you can have a look.

  • johnjohn123 Profile Picture
    3,514 on at

    @ScottShearer i think the index greaterOrEquals(indexOf('/Clients/',[Reference to the path from Dynamic props]),0) 

     

    need to be backwards as follow:-

     

    greaterOrEquals(indexOf([Reference to the path from Dynamic props],'/Clients/'),0) ??

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 816

#2
Valantis Profile Picture

Valantis 603

#3
Haque Profile Picture

Haque 566

Last 30 days Overall leaderboard