cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JRuss
Helper II
Helper II

I want to create a button that changes the DataSource for everything

My current state includes mirrored PROD and DEV environments: Two separate SharePoint lists, each with their own InfoPath form front end and Power Automate approval and email workflows; PROD sends emails to company departments, DEV sends emails to me for testing purposes.  I am working on a new Power App version of the application, and I think ideally I want a single Power App front end, with the ability to click a button that changes the data sources.  This way, when submit is pressed, the data is written to the DEV list instead of PROD, which fires the DEV flows, which sends the emails to me only for testing.  Is there a way to accomplish this?

3 REPLIES 3
BCLS776
Super User
Super User

Unfortunately, Power Apps' structure limits your ability to do dynamic changes to data sources such as this, and it is further complicated when the data sources are in different environments. The Power Apps service needs to connect and read the schema of a data source before runtime and will show an error if the data source is not present in the environment. 

Consider adding this to the Ideas part of the forum to see if Microsoft could work this capability into the platform in the future.

 

Bryan

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
Drrickryp
Super User
Super User

@JRuss 

Why not have two datasources in the same app. Duplicate your forms for each datasource and hide one depending on the status of a toggle or radio button. Use the OnSuccess property of the form to trigger your flow.

Mike2500
Super User
Super User

Look into solutions, which allow you to have environment variables, which allows you to run the same app in two different environments, and to use the connection string in the environment variable to determine which data source to use. This means that you can have the dev app running which connects to the dev lists, and then "deploy" it to prod which then uses the prod lists. 

 

Granted, it's a kludge to get the app published from dev to prod, and this whole scenario is way more difficult than it needs to be, but perhaps it would help you out.

 

Or, write your app so that all forms and galleries get their data from collections, and you could have if statements that load the collections based on whether the app is running in dev mode or not. You'd also need if statements when patching to patch to the correct data source. 

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.

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 (3,262)