cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vkgarapa
Frequent Visitor

Create Dependency between 2 dropdowns

Hello there,

 

I have created two flows where flow-1 gives me the list of folder names present in my onedrive. flow-2 takes input from power apps to display the list of file names present in a folder. Now on the power apps, I was able to get the list of folder names on my Dropdown-1. How do I use the list of folder names from Dropdown-1 as an input to my flow-2 to display the list of the file names present in that folder on Dropdown-2 on power apps.

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @vkgarapa ,

Do you want to have two drop downs, one to list all folders in one drive, one to list all files based on the folder that you select in drop down1?

If so, you need firstly create two flows for these two drop downs. These two are a little different.

The flow for drop down1 needs to use action: list files in root folder

The flow for drop down2 needs to use action: list files in folder

Please pay attention that the parameter in flow2 needs to be folder ID, not folder name.

You just need to set this parameter in flow2 as Ask in powerapps, then get folder ID based on the selection of drop down1.

 

I've made a similar test for your reference:

1)flow1:(attachment476)

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

concat(variables('FileNameString'),'#',item()?['DisplayName'],':',item()?['IsFolder'],':',item()?['Id'])

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

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

 

2)flow2:(attachment477)

Within the "List files in folder" action , set the Folder field to Ask in PowerApps.

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

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

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

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

3)in powerapps

set the screen's OnVisible:

 

 

Set(folders,onedrive.Run().filenamestring);
//onedrive is my flow1 name
ClearCollect(FolderTable1,Split(folders,"#"));
ClearCollect(FolderTable2,AddColumns(FolderTable1,"filename",First(Split(Result,":")).Result,"fileid",Last(Split(Result,":")).Result,"isfolder",Last(FirstN(Split(Result,":"),2)).Result));
Set(files,'Copyof-onedrive'.Run(Dropdown1.Selected.fileid).filenamestring);
//Copyof-onedrive is my flow2 name
ClearCollect(FileTable,Split(files,"#"))

 

 

set drop down1's Items:

 

 

Filter(FolderTable2,isfolder="True")

 

 

set drop down1's OnChange:

 

 

Set(files,'Copyof-onedrive'.Run(Dropdown1.Selected.fileid).filenamestring);ClearCollect(FileTable,Split(files,"#"))

 

 

set drop down2's Items: FileTable

 

 

 

When you load this screen, you will call flow1 and flow2. You will get folders in drop down1.Drop down2 will display files in the first folder by default. If you make selection in drop down1, you will recall flow2 to get files in other folder. Then files in drop down2 will change. It will change to the files in the folder that you select in drop down1.

 

Best regards,

Community Support Team _ Phoebe Liu
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

2 REPLIES 2
eka24
Super User
Super User

Set a Variable:
Set(MyDrop1,Dropdown1.Selected.Value)

Then use the name of the variable MyDrop1 as the default of dropdown2

 

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

v-yutliu-msft
Community Support
Community Support

Hi @vkgarapa ,

Do you want to have two drop downs, one to list all folders in one drive, one to list all files based on the folder that you select in drop down1?

If so, you need firstly create two flows for these two drop downs. These two are a little different.

The flow for drop down1 needs to use action: list files in root folder

The flow for drop down2 needs to use action: list files in folder

Please pay attention that the parameter in flow2 needs to be folder ID, not folder name.

You just need to set this parameter in flow2 as Ask in powerapps, then get folder ID based on the selection of drop down1.

 

I've made a similar test for your reference:

1)flow1:(attachment476)

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

concat(variables('FileNameString'),'#',item()?['DisplayName'],':',item()?['IsFolder'],':',item()?['Id'])

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

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

 

2)flow2:(attachment477)

Within the "List files in folder" action , set the Folder field to Ask in PowerApps.

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

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

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

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

3)in powerapps

set the screen's OnVisible:

 

 

Set(folders,onedrive.Run().filenamestring);
//onedrive is my flow1 name
ClearCollect(FolderTable1,Split(folders,"#"));
ClearCollect(FolderTable2,AddColumns(FolderTable1,"filename",First(Split(Result,":")).Result,"fileid",Last(Split(Result,":")).Result,"isfolder",Last(FirstN(Split(Result,":"),2)).Result));
Set(files,'Copyof-onedrive'.Run(Dropdown1.Selected.fileid).filenamestring);
//Copyof-onedrive is my flow2 name
ClearCollect(FileTable,Split(files,"#"))

 

 

set drop down1's Items:

 

 

Filter(FolderTable2,isfolder="True")

 

 

set drop down1's OnChange:

 

 

Set(files,'Copyof-onedrive'.Run(Dropdown1.Selected.fileid).filenamestring);ClearCollect(FileTable,Split(files,"#"))

 

 

set drop down2's Items: FileTable

 

 

 

When you load this screen, you will call flow1 and flow2. You will get folders in drop down1.Drop down2 will display files in the first folder by default. If you make selection in drop down1, you will recall flow2 to get files in other folder. Then files in drop down2 will change. It will change to the files in the folder that you select in drop down1.

 

Best regards,

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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,493)