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

Use Onedrive connection to look in folder Help

Hi, 

 

So what I would like to do is be able to use powerapps to look in a onedrive folder, such as a folder that I hold a ton of pdfs in. I would like to get '{filenamewithextension}' from all the items in that folder.

This way my end users can use a gallery that shows all of these items and then select one and then view that pdf using the pdf viewer in powerapps or launching that item through the url to that pdf.

 

This is possible to do through sharepoint but I am curious if this was possible to do with onedrive as it is more than likely we are going to use that instead to hold all our pdfs.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Use Onedrive connection to look in folder Help

Hi @Naireb,

Do you want to list all PDF files name in a OneDrive folder within PowerApps?

If you want to list all PDF files name in a OneDrive folder within PowerApps, I think there is no direct way to achieve your needs in PowerApps currently.

I agree with @WPB's thought almost. You could consider take a try to list all PDF file names within a flow, then concatenate these file names into a single one string value with a specific separator (e.g. #), then within your app, you could split the string value into a table value using Split function.

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

The OneDrive folder structure as below:5.JPG

The Flow's configuration as below:6.JPG

 

7.JPG

Within the "Compose" action (in "Apply to each" action), set the Inputs field to following formula:

concat(variables('FileNamesString'),'#',item()?['DisplayName'])

Within the "Compose 2" action, set the Inputs field to following:

substring(variables('FileNamesString'),1,sub(length(variables('FileNamesString')),1))

Note: The FileNamesString represents the variable initialized using "Initialize variable" action.

The flow works successfully as below:8.JPG

More details about using WDL expression in flow actions, please check the following blog:

https://flow.microsoft.com/en-us/blog/use-expressions-in-actions/

 

App's configuration:9.JPG

 

10.JPG

Set the OnSelect property of the "Call Flow" button to following formula:

Set(FileNames,'20181101_case7'.Run().filenamesstring);
ClearCollect(FileNamesTable,Split(FileNames,"#"))

Set the Items property of the Gallery control to following formula:

FileNamesTable

More details about returning data from Microsoft Flow to PowerApps, please check the following blog:

https://flow.microsoft.com/en-us/blog/return-data-to-powerapps/

More details about starting a flow from an app, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/using-logic-flows

 

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.
5 REPLIES 5
WPB
Level 8

Re: Use Onedrive connection to look in folder Help

With OneDrive, you need to use Microsoft Flow for each individual files. I did something like this by populating a list with all the files and then, use the list in PowerApps. When the user wants to see the file, I use a flow to get the Thumbnail image (Faster) and show it in PowerApps.

 

Not a good solution but, it's really limited with OneDrive... 

 

 

Otherwise, you could make a "For each" in Flow to build a list of the files in a specific folder with their shared link and then return it to PowerApps (In a collection). That way, the gallery would show the images and other properties that you wish. Slow but always up-to-date.

Naireb
Level: Powered On

Re: Use Onedrive connection to look in folder Help

@WPB, how do I retrieve this list of file in folder after the flow runs? All I would need from the pdfs is the name and I can generate the URL from there. 

WPB
Level 8

Re: Use Onedrive connection to look in folder Help

2 Options:

The first and simplest way is to construct a string separated with; or some other specific character in Flow before returning it to PowerApps. In PowerApps, you create a collection by splitting this string by using the specific character.

 

The second, more complex solution is to return the array using the "Response" in Flow. I'm having problems with this right now but, it's worth a try since it's the most powerful solution. 

 

Community Support Team
Community Support Team

Re: Use Onedrive connection to look in folder Help

Hi @Naireb,

Do you want to list all PDF files name in a OneDrive folder within PowerApps?

If you want to list all PDF files name in a OneDrive folder within PowerApps, I think there is no direct way to achieve your needs in PowerApps currently.

I agree with @WPB's thought almost. You could consider take a try to list all PDF file names within a flow, then concatenate these file names into a single one string value with a specific separator (e.g. #), then within your app, you could split the string value into a table value using Split function.

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

The OneDrive folder structure as below:5.JPG

The Flow's configuration as below:6.JPG

 

7.JPG

Within the "Compose" action (in "Apply to each" action), set the Inputs field to following formula:

concat(variables('FileNamesString'),'#',item()?['DisplayName'])

Within the "Compose 2" action, set the Inputs field to following:

substring(variables('FileNamesString'),1,sub(length(variables('FileNamesString')),1))

Note: The FileNamesString represents the variable initialized using "Initialize variable" action.

The flow works successfully as below:8.JPG

More details about using WDL expression in flow actions, please check the following blog:

https://flow.microsoft.com/en-us/blog/use-expressions-in-actions/

 

App's configuration:9.JPG

 

10.JPG

Set the OnSelect property of the "Call Flow" button to following formula:

Set(FileNames,'20181101_case7'.Run().filenamesstring);
ClearCollect(FileNamesTable,Split(FileNames,"#"))

Set the Items property of the Gallery control to following formula:

FileNamesTable

More details about returning data from Microsoft Flow to PowerApps, please check the following blog:

https://flow.microsoft.com/en-us/blog/return-data-to-powerapps/

More details about starting a flow from an app, please check the following article:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/using-logic-flows

 

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.
Naireb
Level: Powered On

Re: Use Onedrive connection to look in folder Help

@v-xida-msft, any reason why it only pulls 20 items?

 

I have many more items, around 200+, and it is only pulling the first 20.

Capture.PNG