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

Can't find record to update

I have a collection where I want to update one record, but I'm having a hard time. If I say {first(collection)}, it works fine, but if I say something like {ID: variableID}, nothing happens. I'm not even sure how to troubleshoot since I don't know where it logs errors. Below is a more detail snapshot of the code I'm trying to use.

 

Update(collection, {ID: varID}, {Field: changedField})
1 ACCEPTED SOLUTION

Accepted Solutions
AAK1
Level: Powered On

Re: Can't find record to update

I got it working. I had some required fields in the collection that I wasn't including in the fields to be updated. I thought that you could leave the fields that you didn't want to update out, but I guess not.

 

Thanks for all your help!

View solution in original post

9 REPLIES 9
Super User
Super User

Re: Can't find record to update

Hi @AAK1,

Try Patch(collection, ID=varID, {Field: changedField}).  I am assuming that varID is coming from some control like a Dropdown, Gallery or DataTable.  Update is used to change an entire record.  In your case, Patch is used just to change the value in one field of a record. 

ref: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

AAK1
Level: Powered On

Re: Can't find record to update

When I try , it doesn't recognize "ID" as valid even though it is a field in my collection. I checked both patch and update. I imagine this is my problem, but I don't know how to fix it.

Super User
Super User

Re: Can't find record to update

@AAK1,

I made an error in the patch formula. It should be Patch(collection,Lookup(collection, ID=varID), {Field: changedField})

AAK1
Level: Powered On

Re: Can't find record to update

For some reason this isn't working either. I'm not getting an error of any sort, it's just not patching the record.

Super User
Super User

Re: Can't find record to update

It looks like varID a context variable. What is it an alias for?
AAK1
Level: Powered On

Re: Can't find record to update

It's storing the ID of a selected gallery item. I also tried using gallery.selected.ID instead of a variable.

Super User
Super User

Re: Can't find record to update

The syntax is correct as long as your gallery name is correct and your capitalization is right. I don't know why it isn't working unless the is a value/text discrepancy between your collection field and the update field.
AAK1
Level: Powered On

Re: Can't find record to update

I got it working. I had some required fields in the collection that I wasn't including in the fields to be updated. I thought that you could leave the fields that you didn't want to update out, but I guess not.

 

Thanks for all your help!

View solution in original post

Super User
Super User

Re: Can't find record to update

Great! Please mark the thread as solved so others might avoid the problem.

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,025)