web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to reference a dat...
Power Apps
Answered

How to reference a datasource without loading it (i.e. a pointer)

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi, I am currently building an app with multiple datasources which may or may not be accessible by all users. So upon starting the app, I want to create a collection that has all of the datasources that a user can access for easy reference. I am trying to do something as follows (in pseudo code) :

Adrian2_0-1595905629573.png

However, this solution actually loads the datasource into my collection which I do not want. Is there a way to reference the datasource without actually loading it into the collection? (Or in programming terms is it possible to create a pointer for datasources?)

Categories:
I have the same question (0)
  • Joel CustomerEffective Profile Picture
    3,224 on at

    Build an app launcher app that launches different apps rather than trying to do all of it in one app. All connections neede by your app need to be connected to your app and will need to be authenticated by the user

     

    see the Microsoft healthcare emergency response app solution for a good example of this. The main app has a menu and each menu option is a different app https://powerapps.microsoft.com/en-us/blog/emergency-response-solution-a-microsoft-power-platform-solution-for-healthcare-emergency-response/

     

    that way you can conditionally give access without the users having access to all of the connections 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @jlindstrom ,

    Thanks for your suggestion. However, it is not a viable solution for my case as there will be around 10 different data sources and different users will have access to different permutations of the data sources which will require way too many apps. Is there a workaround for this?

     

    As for the connection requirement, I am using SharePoint lists as the datasource and the app can still launch and work normally even if the user cannot access all the lists.

     

     

  • Joel CustomerEffective Profile Picture
    3,224 on at

    I see you are using 10 sharepoint lists which is one connection, so that solves the login issue. When I was talking about different fldatasourcrs I meant different connections

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Could you please share more details about your scenario?

    After my test, I found your solution seems feasible, it could be something logic error if it loads the datasource into my collection which I do not want, please share more information about it.

     

    In my test, it can embed all list tables into Data Source column in collection, and take Name column as index to reference the Table when I use this code.

    Clear(Coltotal);
    Collect(Coltotal,{DataSource:'SP list1',Name:"SP list1"});
    Collect(Coltotal,{DataSource:'SP list2',Name:"SP list2"});

    Snipaste_2020-07-28_13-54-45.pngSnipaste_2020-07-28_13-55-02.png

    Hope this helps.

    Sik
     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-siky-msft ,

    Thank you for the detailed reply! Initially my first thoughts was also to do the same thing as your test. However the problem is that it loads the entire database into the collection. This is a concern because:

    1. It may cause performance issues if there is a large amount of data from each source. Normally only a filtered subset of the data from each datasource is loaded.
    2. The data in the collection is now a separate copy of the data from the datasource. This means that any modification to the data in this collection will not be saved into the original datasource. I have tried to get around this using the Patch function but it does not work.

     To illustrate, I will use the code you have written to load the data into a collection.

    Adrian2_1-1595918397986.png

    Now, I try to update the "Description" field of the last record in "SP list1" using the Patch function. This gives me the following error.

    Adrian2_3-1595918546541.png

     

    Essentially, building on your example, I want to be able to use 

    Adrian2_4-1595919591299.png

    in place of 'SP list1'. The reason for this is so that the user access rights for each list only needs to be checked once on the app initialization. Then, subsequently I can just refer to this collection to know which datasources the user can access rather than having to check through all the datasources again. I hope that I've explained the scenario well enough. Do let me know if there is anything I can elaborate on or if there is any alternative way to achieve what I'm trying to do here. Thanks!

     

     

     

     

  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Sorry, I still don't get what you mean and what you want to do in the App..

    If the available lists are different for each user, how do you ensure that the formula can dynamically select corresponding data source?

     

    Sik

  • timl Profile Picture
    36,778 Super User 2026 Season 1 on at

    Hi @Anonymous 

    Unfortunately, it is not possible to 'point' to a data source, or to store a pointer to a data source in a variable.

    I agree that this would be a great feature and there are similar related posts that you can find in the ideas forum.

    https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Dynamic-Data-Source/idi-p/178095 

    https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Use-a-variable-to-indicate-source-for-patch/idi-p/252890 

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-siky-msft ,

     

    On app start I will check for access to the data sources like using If functions to check for access. The IsEmpty function will throw an error if the user cannot access that list. Thus, only the accessible data sources will be added.

    Adrian2_0-1595924316300.png

    Then, I use my collection to as the datasource for a gallery (i.e. FilterGallery) to generate at runtime buttons that users can click to select the datasource. Note that "DRUPS3" is missing because I cannot access that datasource.

    Adrian2_1-1595924625068.png

    Now, when a user clicks the button, it will change the datasource of a different gallery that I am using to display the data (i.e. DisplayGallery) by simply setting the "Items" property of DisplayGallery to:

    FilterGallery.Selected.DataSource

    Here is the problem, the items shown this DisplayGallery is merely a copy of the original datasources. If there is any change to my original datasources, even if I refresh the connection, the DisplayGallery will not show the changes. The desired behavior is to have a reference to the datasource so that if anything changes, the DisplayGallery will also show the changes when the connection is refreshed. I apologize if it is still a little unclear.

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @timl ,

     

    Thanks for letting me know. Have you had any luck using a workaround for this or something similar?

  • Verified answer
    timl Profile Picture
    36,778 Super User 2026 Season 1 on at

    Hi @Anonymous 

    Unfortunately, I'm not aware of an easy workaround, so I think the best thing to do is to vote for the post on the ideas forum.

    In your case, I think you would probably need to create a SharePoint list that contains the users and the data sources that they can access. You can then use this to populate your FilterGallery.

    The Items property of your FilterGallery would contain a Switch/If statement that refers to FilterGallery. ie

    Items = If(FilterGallery.Selected.DataSource = "DRUPS2", 'Drups Incidents_2', etc..

    I agree this isn't pretty, but I don't think there is any other alternative at this point.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 577

#2
WarrenBelz Profile Picture

WarrenBelz 440 Most Valuable Professional

#3
Haque Profile Picture

Haque 308

Last 30 days Overall leaderboard