Hello everyone,
I hope you're all doing well!
I'm currently working on a Power Apps project and have encountered a challenge that I'd love to get your insights on. Specifically, I'm trying to update a SQL table using the Patch() function, while leveraging a global variable to dynamically reference different tables.
Here's the scenario:
- I have multiple SQL tables connected to my app.
- I want to display these tables as selectable items in a gallery.
- Upon selecting a table, I aim to assign it to a variable and use this variable to patch data to the selected table.
Despite my efforts, I'm running into issues with the Patch() function not recognizing the variable as a valid data source. Has anyone successfully implemented a similar solution or have any tips on how to achieve this?
Here is the method I followed and failed:
Let's assume that I have SQL tables connected to the app (
Table1, Table2, Table3). First I create a collection of the connected tables:
ClearCollect(TableCollection,
{TableName: "Table1", TableRef: 'Table1'},
{TableName: "Table2", TableRef: 'Table2'},
{TableName: "Table3", TableRef: 'Table3'}
);
And then I put this collection in Items property of a gallery and Set a global variable from the OnSelect property:
Set(selectedTable, ThisItem.TableRef);
Then I try to update the table with something very simple such as:
Patch(
selectedTable,
Defaults(selectedTable),
{
Column1: "First input"
}
)
But I fail and receive the error:
Data source supplied to the function is invalid.