cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tony_921
New Member

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
v-xida-msft
Community Support
Community Support

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

9 REPLIES 9
v-xida-msft
Community Support
Community Support

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.

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 !

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.

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

I marked this as answer question for now.

 

Thanks for your help !

 

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

DarrenPlant
Helper II
Helper II

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?

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

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

DarrenPlant
Helper II
Helper II

No I did not.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,475)