cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jster24
Level: Powered On

Patch SharePoint List from Gallery View

I have a SharePoint list that I want to update columns on. And I believe I need to do this with "Patch". The way I currently have it set up is by using a button on a gallery view page. I am pretty new to this, so not sure all the pieces needed to complete this action, or if have a button with a formula in the "OnSelect" option will work. 

 

Here's the formula I have, but as most things I initially try has the red squiggly line of doom, and doesn't function:

 

Patch('Q-Central Package Tracking', First( Filter( 'Q-Central Package Tracking', Initial_x0020_Destination.Value = "Ecart") ), { Final_x0020_Destination.Value: "EMR"} ) 

I haven't used the gallery view as the way to filter what I want updated, though to me that made sense to do that, but I couldn't get that to work...

Q-Central Package Tracking - is the data source. 

Initial Destination is the column I am filtering what records I want to update 

Final Destination is the column I want to update. 

Have I written this formula correctly to update Final Destination? (It tells  me my "Patch Function has some invalid arguements"

Should I then have some sort of navigation added to the end of the formula so that my gallery view is updated to show only records that didn't get updated?

Is a button function enough?

 

This is a modern list, on an O365 environment. 

2 REPLIES 2
Community Support Team
Community Support Team

Re: Patch SharePoint List from Gallery View

Hi @jster24,

 

I understand that you want to change the Final Destination column of all the items that have "Ecart" in Initial Destination column to "EMR" at one time in Gallery. 

 

You are using the Patch function to modify a set of records in a data source. The formula should be like:

Patch( DataSource, BaseRecordsTable, ChageRecordTable1, [, ChangeRecordTable2, … ] )

 

But in your formula, the ChageRecordTable1 is incorrect, you didn't include the Title column and other columns that are required.

 

Also, I wonder what is the column type of Final Destination. If it is a single line of text field, then your patch statement will be easy. Just remember to patch the title every time when you do an insert or an update. 

 

Here are the common columns that you can do a normal patch to:

  • Date and Time
  • Single line of text
  • Yes / No

These column types require a little more work:

  • Person or Group
  • Choice
  • Lookup

For these column types, you must patch a record inside of your record for the insert or update to work. There’s a special column type called “@odata” that you’ll need to pass over.

 

A simple trick that we use at Confluent is to create a Gallery on a blank page, and pull back a set of records from the SharePoint list. Using the gallery, you can quickly see what items need to be passed to get the patch to work.

 

For example - Choice Column

I have a column called “System Type” in SharePoint, and it is a Choice column. When patching these column back to your SharePoint list, you’ll need a Patch statement that looks like this:

powerapps-sharepoint-patch-statement-300x115.png

 

First check to see if you have an internet connection, then set up your patch statement to your SharePoint list. After that, do an update to your SharePoint list to update the record based on the Record ID in SharePoint.

 

 

To the right of that, you need to pass in a record {}. In this example, we’re going to pass three items as that record:

  1. The @odata type (which you can find by using the Gallery trick);
  2. the Value (a dropdown in PowerApps); and
  3. an ID.

We have found that you can pass one each time, and the drop-down will update. This might change in the future. If you can, build your drop-down box in PowerApps to list the ID and the name in the drop-down, and pass the ID to this.

 

Regards,

Mona

 

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
jster24
Level: Powered On

Re: Patch SharePoint List from Gallery View

Hi @v-monli-msft,

 

It is a choice data field, so it's good to know that it requires a little different components. I am still having trouble, and not fully understanding some of the required components. I'm not sure what my BaseRecord would be. 

 

I've tried different variations of this in hopes that it works. While I no longer get the triangle of exclaimation I am getting the blue informational circle. But first I just wanted to check a couple of things so I know I am doing close to the right thing, as I am pretty new and not sure of this environment yet. I am putting this in a button and have written the formula in the "OnSelect" function. I put this button on a browsegallery screen. Is this all right for getting this to function?

Will I need to navigate to somewhere else after hitting this button for it to refresh the screen of the changes?

 

Here are the iterations of the formulas I have tried. 

Patch('Q-Central Package Tracking', First( Filter( 'Q-Central Package Tracking', Initial_x0020_Destination = "Ecart") ), 
{Final_x0020_Destination.Value: {"@odata_Type: "@Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Value:EMR_DO.Selected.Value} )
Patch('Q-Central Package Tracking', First( Filter( 'Q-Central Package Tracking', Initial_x0020_Destination.Value = "Ecart") ), 
Final_x0020_Destination: {Value: EMR.Selected.Value, '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"}

I am very stuck! Any help would and guidance would be appreciated!

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,510)