Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Components - work around no data source access

(0) ShareShare
ReportReport
Posted on by 241
I'm writing an app that requires offline capability. As such, in places where data should be saved to the data source, the connection status is checked. If there's no connection, changes are saved to a local buffer, to be saved later.

 

I'm working on the 'saving later' part now. I really want this to be done from any screen, but since there may be multiple buffers I don't want to be copy/pasting a lot of save code all over my app (can you spell 'maintenance horror?' 😉 )

 

That's why I tried using a component, as it's easy to add to any screen and it provides a central place for the save code. The component consists of a label that is visible if any save buffer contains data, and a timer that will take care of checking connection and sending the data when it can. But I'm now running into what I think is listed as a known limitation: "data sources aren't saved with components, so forms and data tables are disabled". The code doesn't recognize the datasource in my Patch( datasource, ... ) code...

 

Is there any smart way to work around this limitation? As I stated, I really, really don't want to be copy/pasting the same code all over, and while I could write a separate 'flush all buffered data' screen that I could let the user navigate to, that would be really interrupting a natural flow throughout the app.

  • KRider Profile Picture
    577 Super User 2024 Season 1 on at
    Re: Components - work around no data source access

    Currently I have a button in my application that reads all of the output values from my "Settings" pop up. It then patches. This can be time consuming if I ever need to change the button. 

     

    I'm working on writing a new output property that can loop and patch. Not sure if it will work.

  • SytzeVisser Profile Picture
    31 on at
    Re: Components - work around no data source access

    Hi

     

    It's 2022 and the capability is not yet available. 

     

    The workaround though is to create a process in Power Automate that does the saving of the the record. I was concerned about performance but that does not seem to be an issue.  Hope it helps.

     

    Best regards

  • MrNappa Profile Picture
    241 on at
    Re: er Re: Components - work around no data source access

    Appreciate the input, but the challenge here was not the save code itself, but trying to centralize patch code in a component so it can be used in different screens.  This is not really possible, and now that I have some more experience with and knowledge of the platform, I doubt something like this will be implemented within components because of the technical implications this has.

  • Community Power Platform Member Profile Picture
    on at
    er Re: Components - work around no data source access

    Have you tried using a hidden timer control that you can trigger by a variable? A form is another option, especially if data is being submitted. You can use the OnReset for some values. I use these two solutions in my apps for reused code quite frequently.

  • RBoneck Profile Picture
    409 on at
    Re: Components - work around no data source access

    If I were you I would skip the component altogether and just use the new Select() function!

    Edit: At the time I did not realize that the Select() function had such a serious limitation as you cannot select something on a different screen. Making my solution pretty much useless! In an actual answer to this issue, I've used collections made onstart as the datasource for components with great success. If you have less than 2000 records, you can make a perfect copy of a datasource very easily with something like ClearCollect(CollectedDataSource, DataSource)

  • MrNappa Profile Picture
    241 on at
    Re: Components - work around no data source access

    Seems like nobody has a hack, so I'll just mark your reply as 'answer'. Thanks for thinking with me.


    Idea post I made for reference and great justice:

    https://powerusers.microsoft.com/t5/PowerApps-Ideas/Allow-access-to-data-source-from-within-components/idi-p/365979

  • MrNappa Profile Picture
    241 on at
    Re: Components - work around no data source access

    Yes, ideally I want the Patch command to the datasource to be executed from the component. As I described in the scenario, this would allow me to use the component in every screen to send buffered data once the connection is online. As opposed to duplicate this code everywhere.

     

    Admittedly, trying to centralize my buffer saving code in a component is already a bit of a hack, because there is no way of doing so in some kind of background process.

     

    I know it is currently a limitation (I included a link to the relevant documentation earlier, but a bot marked that post as spam), that's why I was wondering if someone would have thought some kind of clever way to work around this.

    I'll post this to the ideas section too, but I won't get my hopes up 😅.

  • Verified answer
    v-xida-msft Profile Picture
    on at
    Re: Components - work around no data source access

    Hi @MrNappa ,

    Do you want to execute the Patch formula within your Component control?

    Do you want the data source could be recognized within your Component control?

     

    It is an known limit with Component control in PowerApps. The data source you added in your app could not be recognized within the Component control.

     

    If you want to execute the Patch formula within your Component control, I afraid that there is no way to achieve your needs in PowerApps currently.

     

    If you would like this feature to be added in PowerApps, please consider submit an idea to PowerApps Ideas Forum:

    https://powerusers.microsoft.com/t5/PowerApps-Ideas/idb-p/PowerAppsIdeas

     

    Best regards,

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,660 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard