cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MrNappa
Kudo Commander
Kudo Commander

Components - work around no data source access

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.

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

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,

Community Support Team _ Kris Dai
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

7 REPLIES 7
v-xida-msft
Community Support
Community Support

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

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

Boneckrh19
Kudo Kingpin
Kudo Kingpin

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)

Anonymous
Not applicable

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.

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
Frequent Visitor

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

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,144)