cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ACPBSCi
Helper III
Helper III

Patch feature doesn't recognize column

I'm trying to update an existing record with a group of users who are added later. The Users column is a multi-line text field. I have in use in the app the list name, the ID of the previously created item in a variable, and a collection and a string of the users. What I don't have at use in the app is the actual Users column that I want to update. When I add the patch to my submit button, it says it doesn't recognize the column:

Patch('My List Name',{ID: Value(ItemID.Text)},['Users':AllItemsString])

I also tried it with UpdateIf, but then I get errors about improper use of the colon:

UpdateIf('My List Name',ID: Value(ItemID.Text),{Users:AllItemsString})

I'm sure my syntax is wrong, but from what I found online through Microsoft and through other questions posted to the community, it looks right. Any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions

GOT IT!! Yes, the Patch feature is hugely useful and powerful and yes, insanely complicated to understand. After a bit of trial and error:

Patch('My List Name', LookUp('My List Name',ID=Value(ItemID_1.Text)),{Users:AllItemsString})

Note the subtle differences. This is working and I am thrilled! Thank you @Drrickryp

View solution in original post

3 REPLIES 3
Drrickryp
Super User II
Super User II

Hi @ACPBSCi 

Typically, patch syntax has three parts, the datasource being patched, the record being patched and the fields being patched. 

 

Patch(Datasource, Lookup(Datasource,ID=Gallery1.Selected.ID),{Field1:Dropdown1.Selected.Value,Field2:Datepicker1.SelectedDate,Field3:TextInput1.Text, etc})

 

In the event that a new item is being added, then the second element is  changed to Defaults(Datasource) to indicate that this is a new item that is using the default fields. 

 

Patch(Datasource, Defaults(Datasource),{Field1:Dropdown1.Selected.Value,Field2:Datepicker1.SelectedDate,Field3:TextInput1.Text, etc})

 

The fields use a colon to indicate the name of the field (column) and where the data is coming from. Commas separate the fields.  and all of the fields are enclosed in curly braces.


Patch is one of the most versatile PowerApps functions but it is also very confusing to new developers. ref https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch 

 

For more information on Patch and SharePoint complex column types, see https://www.c-sharpcorner.com/article/powerapps-patch-fuction-with-complex-columns/ 

 

I'm still getting errors. I have entered this:

Patch('My List Name', Lookup('My List Name',ID=ThisItemInfo_1.ItemID_1.ID),{Users:AllItemsString})

and I get the following errors:

  • The = in gives an error of "invalid argument type"
  • The .ItemID_1 gives an error of "Name isn't valid. This identifier isn't recognized."
  • The .ID gives an error of "Invalid use of ' '."

".ItemID_1" is a label. Is that the issue? I couldn't figure out how to get the actual ID field into my gallery, it only seems to let me add labels. So I added a label, had it display the ID for the current item, then save that ID to a variable for use later on. Do I need the actual ID field in order to make this work? Can I use the variable instead?

GOT IT!! Yes, the Patch feature is hugely useful and powerful and yes, insanely complicated to understand. After a bit of trial and error:

Patch('My List Name', LookUp('My List Name',ID=Value(ItemID_1.Text)),{Users:AllItemsString})

Note the subtle differences. This is working and I am thrilled! Thank you @Drrickryp

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

Top Solution Authors
Top Kudoed Authors
Users online (90,294)