cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Community Support
Community Support

Re: Create Dependency between 2 dropdowns

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 Community Champion
Community Champion

Re: Create Dependency between 2 dropdowns

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.

Community Support
Community Support

Re: Create Dependency between 2 dropdowns

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

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (9,270)