cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mrjrobinson
Frequent Visitor

Data not updating from edit in Gallery

Hi There,

 

First off I am a novice to all of this so please bare with me. 

 

I have created a gallery with a edit button, when I click on this the fields become "Editable" and I make my changes to the record. When I click on my save button this writes to my spreadsheet connection but as a new entry instead of updating the existing entry. I have watched a lot of videos to piece this together. Here is my formula:


UpdateContext({EditRecord: " "});Patch('Member Tracker',{Membership_x0020_Number:ThisItem.Membership_x0020_Number},
{Member_x0020_Name: MembersNameInputField.Text,
Membership_x0020_Number: MembershipNumberInputField.Text,
Membership_x0020_Type:MembershipTypeInputField.Text,
Member_x0020_Status:MemberStatusInputField.Text,
Payment_x0020_Date:PaymentDateInputField.Text,
Email_x0020_Address:EmailAddressInputField.Text,
Mobile_x0020_Number:ContactNumberInputField.Text,
Notes:NotesInputField.Text})

 

Any help you can provide would be great!

Thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Data not updating from edit in Gallery

@mrjrobinson 

Hello there and welcome to the PowerApps community.  I can see the reason why your PATCH is not updating the current record as you expected.  It is because of this code segement in the 2nd argument of PATCH.

 

{Membership_x0020_Number:ThisItem.Membership_x0020_Number}

 

The 2nd argument of PATCH references the record to be updated.  What you have done is created a whole new record by putting some data between the curly brackets { }.  Instead what you should do is replace it with this code.

 

ThisItem

  

ThisItem returns the current record in the gallery the Save button is placed within and it is a record data type.  If you are familar with LookUp it achieves the same result current record like this.

 

LookUp('Member Tracker',ID=ThisItem.ID)

 

To recap, here's the full code you should use.

 

UpdateContext({EditRecord: " "});
Patch(
    'Member Tracker',
    ThisItem,
    {
        Member_x0020_Name: MembersNameInputField.Text,
        Membership_x0020_Number: MembershipNumberInputField.Text,
        Membership_x0020_Type:MembershipTypeInputField.Text,
        Member_x0020_Status:MemberStatusInputField.Text,
        Payment_x0020_Date:PaymentDateInputField.Text,
        Email_x0020_Address:EmailAddressInputField.Text,
        Mobile_x0020_Number:ContactNumberInputField.Text,
        Notes:NotesInputField.Text
    }
);

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

6 REPLIES 6
Super User
Super User

Re: Data not updating from edit in Gallery

Can you try this version of Patch?

UpdateContext({EditRecord: " "});Patch('Member Tracker', ThisItem,
{Member_x0020_Name: MembersNameInputField.Text,
Membership_x0020_Number: MembershipNumberInputField.Text,
Membership_x0020_Type:MembershipTypeInputField.Text,
Member_x0020_Status:MemberStatusInputField.Text,
Payment_x0020_Date:PaymentDateInputField.Text,
Email_x0020_Address:EmailAddressInputField.Text,
Mobile_x0020_Number:ContactNumberInputField.Text,
Notes:NotesInputField.Text})

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
Super User
Super User

Re: Data not updating from edit in Gallery

@mrjrobinson 

Hello there and welcome to the PowerApps community.  I can see the reason why your PATCH is not updating the current record as you expected.  It is because of this code segement in the 2nd argument of PATCH.

 

{Membership_x0020_Number:ThisItem.Membership_x0020_Number}

 

The 2nd argument of PATCH references the record to be updated.  What you have done is created a whole new record by putting some data between the curly brackets { }.  Instead what you should do is replace it with this code.

 

ThisItem

  

ThisItem returns the current record in the gallery the Save button is placed within and it is a record data type.  If you are familar with LookUp it achieves the same result current record like this.

 

LookUp('Member Tracker',ID=ThisItem.ID)

 

To recap, here's the full code you should use.

 

UpdateContext({EditRecord: " "});
Patch(
    'Member Tracker',
    ThisItem,
    {
        Member_x0020_Name: MembersNameInputField.Text,
        Membership_x0020_Number: MembershipNumberInputField.Text,
        Membership_x0020_Type:MembershipTypeInputField.Text,
        Member_x0020_Status:MemberStatusInputField.Text,
        Payment_x0020_Date:PaymentDateInputField.Text,
        Email_x0020_Address:EmailAddressInputField.Text,
        Mobile_x0020_Number:ContactNumberInputField.Text,
        Notes:NotesInputField.Text
    }
);

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Super User
Super User

Re: Data not updating from edit in Gallery

@mdevaney would appreciate acknowledgement if someone posts the same suggested solution before you 🙂

No hard feelings, just a suggestion. Hope you have a great day!
Super User
Super User

Re: Data not updating from edit in Gallery

@PowerAddict 

Sometimes we are posting at the same time so it happens.  I typically open the reply window, go to my app testing environment to build a test and then post a response.  But yes, I do acknowledge that you also have a correct solution here.

Super User
Super User

Re: Data not updating from edit in Gallery

Yup, has happened to me before. No worries!
mrjrobinson
Frequent Visitor

Re: Data not updating from edit in Gallery

Thank you very much for your assistance!

Helpful resources

Announcements
secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

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