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

Data Sources as a Dropdown

Hi Everyone,

 

Is there a way to populate a drop down control with all data sources currently connected to a particular application. For Example If i have 5 sharepoint lists with the same fields and want to be able to select a specific list to view its content. 

 

Thanks for the help,

 

Dave

11 REPLIES 11
nickduxfield
Level 8

Re: Data Sources as a Dropdown

Try toggle the Items attribute with an If statement first with a variable that shadows the connection name. Sounds great.

But,

When you want to filter a gallery/data-table or update a form. You may need to also create an if statement with the variable to switch the following.

 

Dropdown.Selected.Result,

Dropdown.Selected.Value,

Dropdown.Selected.Country

or similar

 

Let us know how you go, I'd be interested

bdodu
Level 8

Re: Data Sources as a Dropdown

I believe the easiest way to achieve it is to bind each datasource to a different gallery and the based on a specific trigger (ex. a dropdown control having the list of available datasources) to show/hide the proper gallery.

 

This way each gallery can be customized according to the list most relevant information (may be pictures in ones)

 

shouldn't be so time consuming for a limited amount of lists ...

 

Another option is to declare a collection with the names of all sources, bind it to a dropdown and then use the switch function to select the proper datasource.

 

Ex.

On the form OnVisible:

 

ClearCollect(DataSources,{DSName:"Source1"}, {DSName:"Source2"},{DSName:"Source3"})

Bind the dropdown to the DataSources collection and then add the gallery and set the Items property:

 

Switch(  Dropdown1.Selected.Value,
"Source1",'[dbo].[view_LeaveBalances]',
"Source2",'[dbo].[view_ActiveEmployees]'
)

 

However when it comes to binding the gallery items to the corresponding data I only managed when all the datasources had the same data structure including column names.

 

Hope it helps, please let us know.

RussellGove
Level 8

Re: Data Sources as a Dropdown

bdodu, so if i have a site with  a bunch of identical sub sites, i can use a single powerapp to work with each of the subsites? users could select the sub site on the welcome page?

 

i would love to see a demo of that !!!!

bdodu
Level 8

Re: Data Sources as a Dropdown

Why not? What's changed? 

We are basically talking about putting together a bunch of datasources having the same structure so at the runtime you'll just be directed to the proper collection. Try follow my steps with 2 simple controls - one dropdown and one gallery. 

 

 

Carefull when it comes to data/users distributed among multiple tenants, hope it's not your case.

RussellGove
Level 8

Re: Data Sources as a Dropdown

single tenant. one site collection with identical sub sites. users  may have access to one or more of those sub sites.

 

a dozen  lists in each sub site.  i'm new to powerapps , so just trying to figure this out. 

bdodu
Level 8

Re: Data Sources as a Dropdown

Ok, try to follow these steps and let me know the result to better understand how to help you.

 

1. Create a new app and connect all the lists in each subsite to your app.

2. Define a static collection with friendly names of each list (my first answer step 1)

3. Bind the dropdown to the collection

4. Connect a gallery to the dropdown with the switch statement (my first answer step 2)

5. Having all the data using the same structure and names you can easily bind the controls within the gallery to the underlying data (using ThisItem.whatever-column-name)

 

By changing the dropdown selection the gallery will display the data from the specific list (within the connected subsite)

bdodu
Level 8

Re: Data Sources as a Dropdown

Did you manage?

RussellGove
Level 8

Re: Data Sources as a Dropdown

I did not. (I'm really new to this).

I could not figure out how to bind my controls to the selected datasource.

But from what im learning, I think I dont want to bind the controls to the datasource. I just want to set the items property of the controls.

 

Running into many that are slowing me down.

RussellGove
Level 8

Re: Data Sources as a Dropdown

btw , I have  a sharepoint backend.


so i cant do

Switch(  Dropdown1.Selected.Value,
       "Source1",'[dbo].[view_LeaveBalances]',
"Source2",'[dbo].[view_ActiveEmployees]'
)

 

 

Will need to set up each 'source' with multiple datasources".  something like:

  {
        DSName: "EUR",
        Sources:
{
            TimeSpent: 'timespentlistfromEUR site',
            Requests: 'requestlistfromeursite'

        }
    },
    {
        DSName: "APAC",
        Sources:
        {
            TimeSpent: 'timespentlistfroAPAC site',
            Requests: 'requestlistfromAPACsite'

        }
    }
  
  

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 85 members 4,918 guests
Please welcome our newest community members: