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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Getting the 2nd folder...
Power Automate
Answered

Getting the 2nd folder name as a variable.

(0) ShareShare
ReportReport
Posted on by 8


Would it be possible to get the 2nd folder name out of OneDrive4Biz ?

 

For example, how can I get a variable "1234" out of "/AssetList/1234/request.docx",

which is from OneDrive4Biz trigger "File path" ?

 

Upon someone creating the "request.docx" inside a specific folder of the OneDrive4Biz,

I want to create a SharePoint custom list item, whose title matches the folder name, "1234".

 

Playing a bit with "Date Operation - Compose" trigger, the "split" function
seems promising, but I couldn't find its full syntax ( or basic usage) to
set its return value to a variable.

 

Thanks in advance !

Categories:
I have the same question (0)
  • Verified answer
    v-xida-msft Profile Picture
    on at

    Hi @Tony_921,

     

    Do you want to get the subfolder of AssetList folder of OneDrive for Business?

     

    I have made a test on my side and please take a try with the following workaround:

    • Add “When a file is created” trigger.
    • Add a Variable-> “Initialize variable” action, Name set to FolderVariable, Type set to String and Value set to empty.
    • Add a “Compose” action, Inputs set to following formula:

     

    split(triggerOutputs()['headers']['x-ms-file-path'],'/')

     

    • Add a “Set variable” action, Name choose FolderVariable, Value set to following formula:

     

    outputs('Compose')?[2]

     

    Image reference:2.JPG

    The flow works successfully as below:3.JPG

     

    More details about expression in Microsoft Flow, please check the following article:

    https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language

     

    Best regards,

    Kris

  • Tony_921 Profile Picture
    8 on at

    Thank you for the very informative reply as well as the screenshot, which really helped me. Without it, the procedure was too complicated to figure out by myself.

     

    Your suggestions works great with sub-folder "1234".

     

    However, I wanted this (single) flow to cover multiple folders, like

     

    /AssetList/1234/request.docx
    /AssetList/1235/request.docx
    /AssetList/1236/request.docx
    ...

     

    That's the reason why I wanted to extract the 2nd sub-folder name as a variable.

     

    If "When a file is created" sets only with "/AssetList", it doesn't seem fire up with new files created under 1235 or 1236 sub-folders.

     

    Is there any setting I might miss to set the "When a file is created" to monitor all sub-folders ?

     

    Thanks for your further help !

  • v-xida-msft Profile Picture
    on at

    Hi @Tony_921,

     

    There is a known issue about File triggers, the file triggers won’t fire for files being added inside of nested folders inside the folder you select.

     

    More details about Known issues and resolutions, please check the following article:

    Known issues and resolutions

     

    Best regards,

    Kris

  • Tony_921 Profile Picture
    8 on at

    Then, I cannot help but just wait for the fix.

    I marked this as answer question for now.

     

    Thanks for your help !

     

  • rupach Profile Picture
    30 on at

    Is their any update on this ? Could anyone  help me on this 

  • DarrenPlant Profile Picture
    77 on at

    I used this from this example/solution split(triggerOutputs()['headers']['x-ms-file-path'],'/')

     

    Main difference is from SharePoint not OneDrive, should that matter.

    However, I get this error:

     

    Unable to process template language expressions in action 'Compose' inputs at line '1' and column '9065': 'The template language expression 'split(triggerOutputs()['headers']['x-ms-file-path'],'/')' cannot be evaluated because property 'x-ms-file-path' doesn't exist, available properties are 'Transfer-Encoding, Retry-After, Vary, X-SharePointHealthScore, X-MS-SPConnector, X-SP-SERVERSTATE, DATASERVICEVERSION, SPClientServiceRequestDuration, SPRequestGuid, request-id, MS-CV, Strict-Transport-Security, X-FRAME-OPTIONS, Content-Security-Policy, MicrosoftSharePointTeamServices, X-Content-Type-Options, X-MS-InvokeApp, Timing-Allow-Origin, x-ms-apihub-cached-response, Cache-Control, Date, Location, P3P, X-AspNet-Version, X-Powered-By, Content-Type, Expires, Last-Modified, Content-Length'.

     

    Can someone please advise?

  • Regash Profile Picture
    10 on at

    Hi, I used your way to get the folder name, but I am not getting the correct output. will appreciate your help on this.

  • rhysgjones Profile Picture
    8 on at

    Did you ever get this working? i am getting the exact same issue with SharePoint

  • DarrenPlant Profile Picture
    77 on at

    No I did not.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 398 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 323 Super User 2025 Season 2

#3
Expiscornovus Profile Picture

Expiscornovus 183 Most Valuable Professional

Last 30 days Overall leaderboard