web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch not working when...
Power Apps
Unanswered

Patch not working when updateing with value selected from a dropdown or combobox populated by SQL view or collection

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have several galleries in my app that are used as an editable grid. As an item is selected in the gallery/grid a context variable is set with the id of that item, if the context variable id matches the id of an item in the gallery that item and the controls associated with that item become editable:

2020-03-12_10-55-57.jpg

2020-03-12_10-57-18.jpg

The Onselect property for the save icon seen in the screenshot above is where are patch is located. please see code below:
Patch(
colEquip,
{EquipmentId: editrecord},
{
EquipmentMaintenanceStatusId:mtequipgridgalmaintstatus_dd.Selected.EquipmentMaintenanceStatusId,
EquipmentMaintenanceStatusName:mtequipgridgalmaintstatus_dd.Selected.EquipmentMaintenanceStatusName,
TestTankStatusId:mtequipgridgaltesttankstatus_dd.Selected.TestTankStatusId,
TestTankStatusName:mtequipgridgaltesttankstatus_dd.Selected.TestTankStatusName,
MaintenanceEstRTSDate: mtequipgridgalrts_date.SelectedDate,
MaintenanceComments: mtequipgridgalmaintcomments_txt.Text,
Bay: mtequipgridgalbay_dd.Selected.BayNumber,
Priority: mtequipgridgalpriority_dd.Selected.Value,
ModifiedBy: User().FullName,
ModifiedDate: Now()
});
Patch(
'[boc].[Equipment]',
{EquipmentId: editrecord},
{
EquipmentMaintenanceStatusId:mtequipgridgalmaintstatus_dd.Selected.EquipmentMaintenanceStatusId,
TestTankStatusId:mtequipgridgaltesttankstatus_dd.Selected.TestTankStatusId,
MaintenanceEstRTSDate: mtequipgridgalrts_date.SelectedDate,
MaintenanceComments: mtequipgridgalmaintcomments_txt.Text,
Bay: mtequipgridgalbay_dd.Selected.BayNumber,
Priority: mtequipgridgalpriority_dd.Selected.Value,
ModifiedBy: User().FullName,
ModifiedDate: Now()
});
UpdateContext({editrecord:""});

As you can see I have 2 patches, one to the collection used to display the data in the app and one to the database to update the SQL back end. This function has worked for almost a year now and just recently seems to be failing intermittently where the collection gets updated but the SQL back end does not. No changes to the code have been made recently, just started failing on its own.

 

Most of the cases seem to involve a dropdown populated by a sql view or collection created from a sql view. When a patch includes a value selected from such a dropdown the patch fails. Furthermore there is no error message, the data simply just does not send.

 

Can I please get some assistance on how to resolve this issue? Has something changed with patches or using sql view data connections?

 

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Try changing the

      {EquipmentId: editrecord}

    To This for the collection:

      Lookup(colEquip, EquipmentId = editrecord)

    And this for the SQL:

      Lookup('[boc].[Equipment]', EquipmentId = editrecord)

     

    Patch should have a full record to patch when possible for reliability.  Simply specifying a single column record with an Id tends to fail often.

     

     

    Also, consider using UpdateIf rather than Patch.  There are a few quirks with patch that UpdateIf eliminates.

    In that case:

      UpdateIf(colEquip, EquipmentId=editrecord, {...the rest of your record})

    and

      UpdateIf('[boc].[Equipment]', EquipmentId = editrecord, {...the rest of your record})

     

     

    I hope this is helpful for you.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Still monitoring the fix performance. Seems to be working well early on.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Unfortunately, I am still seeing intermittent failures. I made the suggested change and at times the changes to the data are still not being submitted to the database. Any other suggestions?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Is there any way you can trace down the intermittent failures?  Is there anything you can do to duplicate?

    That will be key in troubleshooting. 

    I've had to track down a lot of those types before, and find that there is always something that triggers it...maybe even as simple as a calculation of something else that is incorrect. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 421

#2
WarrenBelz Profile Picture

WarrenBelz 345 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 278 Super User 2026 Season 1

Last 30 days Overall leaderboard