cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tony_921
Level: Powered On

Getting the 2nd folder name as a variable.


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 !

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Getting the 2nd folder name as a variable.

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

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Community Support Team
Community Support Team

Re: Getting the 2nd folder name as a variable.

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

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Tony_921
Level: Powered On

Re: Getting the 2nd folder name as a variable.

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 !

Community Support Team
Community Support Team

Re: Getting the 2nd folder name as a variable.

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

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Tony_921
Level: Powered On

Re: Getting the 2nd folder name as a variable.

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

I marked this as answer question for now.

 

Thanks for your help !

 

rupach
Level: Powered On

Re: Getting the 2nd folder name as a variable.

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

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (5,635)