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 / Patching to SQL tables...
Power Apps
Suggested Answer

Patching to SQL tables as global variables

(1) ShareShare
ReportReport
Posted on by 29

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.
 
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,479 Super User 2025 Season 2 on at
    Hi @ege
     
    No, unless it is an environment variable, you have to access via the actual data source.
  • ege Profile Picture
    29 on at
    Hi @Michael E. Gernaey,

    How can I solve this using environment variables?  Never used them before.

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 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard