cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ws_Only
Regular Visitor

Dynamically Adding Data Sources

I'm building a Power App that can connect to SharePoint task lists to update task data. These task lists are created when the using the "Sync with SharePoint" button in its associated Microsoft Project file. The data sources used in Power Apps point directly to the task lists in SharePoint.

 

The problem: when a new task list is created, the app does not automatically create and connect to a new data source for this task list. The data source must manually be added through the user interface in the Power Apps editor.

 

Is there a way to automatically or dynamically load various data sources based on a user's selection within the app, or do all data sources need to be statically set in the Power Apps editor before runtime?

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

In general the connectors pick up the schema of the data source when you create the connection.  This makes it impossible to work with a dynamic connection because the connector doesn't have access to the schema.  I have gotten it to work, but it takes a lot of manual effort because everything needs to be coded as a JSON item record where you supply all the right fields.  That's a requirement because the connection doesn't know what the data source schema looks like because it can't pick it up at runtime.  So yes, its theoretically possible, but extremely difficult and prone to error in practice.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

3 REPLIES 3
Pstork1
Dual Super User
Dual Super User

In general the connectors pick up the schema of the data source when you create the connection.  This makes it impossible to work with a dynamic connection because the connector doesn't have access to the schema.  I have gotten it to work, but it takes a lot of manual effort because everything needs to be coded as a JSON item record where you supply all the right fields.  That's a requirement because the connection doesn't know what the data source schema looks like because it can't pick it up at runtime.  So yes, its theoretically possible, but extremely difficult and prone to error in practice.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Can you please elaborate on the process?

Here's an example.  I put the ListName in a variable and then used it as a custom entry in the Create Item action. Since the list is dynamic the action can't retrieve the schema so the only field I get is Item.  To create an Item I need to define a JSON record with the four fields in the list and their values.  It works, but it means you will always be responsible for creating an Item record with the right schema.

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,913)