Showing results for 
Search instead for 
Did you mean: 
Super User
Super User

Update() function now irreconcileable after adding a Primary KEY index.

I went through great pains to add a primary key to my SQL table so that Patch() and Collect() would work properly.  I also wish to use Update().  Its just a cleaner way to update an entire record in one go.  However, Since the table now has an automatic key, I cant make it go.  If I leave my key column out of my Set() variable, then the command failes because the column is missing.  If I add the column, even if Blank(), it returns: "The specified column is generated by the server and can't be specified."  So, its a Darned if you do, darned if you don't scenario.  I guess Update() is just not applicable with a table with a index??




BTW, Collect() works in a similar fashion.  It works fine.  I guess adding a new row to the table is not affected in the same way.

PowerApps Staff Mr-Dang-MSFT
PowerApps Staff

Re: Update() function now irreconcileable after adding a Primary KEY index.

Hi @martinav ,

There are a few functions to help update a table: Update, UpdateIf, and Patch.


UpdateIf and Patch do not require you to replace the entire row with another full row, so they would be the functions to use in this case.


The Update function requires you to replace an entire row with another full row. But as you have found out, if you have a column whose values must be unique (and it's identity is auto-generated), then this will not work.


Here's the doc in question:

Update function
Use the Update function to replace an entire record in a data source. In contrast, the UpdateIf and the Patch functions modify one or more values in a record, leaving the other values alone.

For a collection, the entire record must match. Collections allow duplicate records, so multiple records might match. You can use the All argument to update all copies of a record; otherwise, only one copy of the record is updated.

If the data source generates a column's value automatically, the value of that column must be reaffirmed.



@timl @v-xida-msft @seadude who can field some additional questions you might have about Patch

Level 10

Re: Update() function now irreconcileable after adding a Primary KEY index.

I LOVE UpdateIf() !
Great use cases:

  • OnChange/OnCheck/OnUncheck of Dropdown/Textbox/Checkbox/Toggles both stand-alone, in Forms and (especially!) in Galleries.
    • Example:
    • If(
          dropdown.Selected.Value <> "defaultValue",
              id = 23 //whatever id OR ThisItem.ID in a Gallery
                  specific field: "toUpdate",
                  other field: "toUpdate"
  • I've been using this a LOT lately for Progress Bars on long forms.
Level 10

Re: Update() function now irreconcileable after adding a Primary KEY index.

PS: I've found Patch does NOT work for Collections of items from Sharepoint lists, @RandyHayes (I think) aimed me at UpdateIf to Patch Collections from SP lists. After reading @Mr-Dang-MSFT 's comment above RE: unique items, I think I now know WHY!

Helpful resources


Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 176 members 5,345 guests
Please welcome our newest community members: