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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Components - work arou...
Power Apps
Unanswered

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.

Categories:
I have the same question (0)
  • Verified answer
    v-xida-msft Profile Picture
    on at

    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,

  • MrNappa Profile Picture
    241 on at

    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 😅.

  • MrNappa Profile Picture
    241 on at

    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

  • RBoneck Profile Picture
    415 on at

    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)

  • Community Power Platform Member Profile Picture
    on at

    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.

  • MrNappa Profile Picture
    241 on at

    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.

  • SytzeVisser Profile Picture
    31 on at

    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

  • KRider Profile Picture
    577 Super User 2024 Season 1 on at

    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.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard