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 / Patching multiple reco...
Power Apps
Unanswered

Patching multiple records in a table, using a dropdown within a gallery

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi there,

 

I am having difficulties patching my table using a gallery dropdown. My aim here is for people to be able to submit their audit incomplete and it is stored into the table like the example below. I the have a patch function where they can go back to their audit and complete it, updating each question "Pass_Fail" which is located within a gallery in image 2. However using the code below is only updating the first record it finds in the table with the call reference lookup, instead of patching every one of them.

 

ForAll(QuestionGal_edit.AllItems, Patch(Audit_answers, LookUp(Audit_answers, call_reference = reference_edit.Text), {call_reference: reference_edit.Text, call_type: Calltype_dropdown_edit.Selected.'Call Type', date_of_audit: Audit_Date_edit.SelectedDate, BU: BU_dropdown_edit.Selected.Value, advisor: Advisor_dropdown_edit.Selected.Advisor_name, Question: 'Question-text_edit'.Text, Pass_Fail: Pass_dropdown_edit.Selected.Value, Feedback: Feedback_dropdown_edit.Selected.Value, bulk_audit: Bulk_1.Text, Satisfaction: Satisfaction_1.Selected.Value}))

 

Does anyone have any advice/ideas on how to fix this?

 

 

mikecampbell260_0-1692697689226.png

mikecampbell260_1-1692697855034.png

Categories:
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    Yes the problem is because you are patching on reference_edit instead of on the current record scope of the ForAll function

    Try this:

     

    ForAll(
     QuestionGal_edit.AllItems,
     Patch(
     Audit_answers,
     LookUp(Audit_answers, call_reference = Audit_answers[@call_reference]),
     {
     call_reference: reference_edit.Text,
     call_type: Calltype_dropdown_edit.Selected.'Call Type',
     date_of_audit: Audit_Date_edit.SelectedDate,
     BU: BU_dropdown_edit.Selected.Value,
     advisor: Advisor_dropdown_edit.Selected.Advisor_name,
     Question: 'Question-text_edit'.Text,
     Pass_Fail: Pass_dropdown_edit.Selected.Value,
     Feedback: Feedback_dropdown_edit.Selected.Value,
     bulk_audit: Bulk_1.Text,
     Satisfaction: Satisfaction_1.Selected.Value
     }
     )
    )
    

     

    See if it helps  @Anonymous 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi,

     

    this is giving an error of "these types cannot be compared: Boolean, Text"

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    I also recommend you consider the following:

     

    1. Patch Outside ForAll

    Collecting changes first and then patching them all at once enhances performance by reducing multiple transactions to the data source.

    In this example: Collect the changes and then use Patch to apply them.

     

    // Collect the changes
    ClearCollect(
     colChanges,
     ForAll(
     QuestionGal_edit.AllItems,
     {
     // Define the changes here. 
     //This may be identical to what you have for the 3rd argument of Patch in your existing formula
     }
     )
    )
    
    // Patch all the changes at once
    Patch(
     Audit_answers,
     QuestionGal_edit.AllItems,
     colChanges
    )
    

     

    2. Avoiding QuestionGal_edit.AllItems

    Gallery.AllItems might not return all items when there's lots of items in the Gallery!

    Patching individual items provides more control.

     

    // Inside a button within a gallery, and for the OnSelect property of this Button:
    Patch(
     Audit_answers,
     {
     ID: ThisItem.ID
     call_reference: reference_edit.Text,
     call_type: Calltype_dropdown_edit.Selected.'Call Type',
     // Other fields...
     }
    )
    

     

    See if this helps as well @Anonymous 

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

     

    yes

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi thank you, I will try this but unsure it will work in my aspect. As the gallery is a set "Questionairre" where a manager will score an advisor based on each question, passing or failing them. then they will submit the questionairre, and update any fields they may have left blank prior

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Anonymous 

    There's a small typo in the formula, let me give you the correct one, hold on.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    This is the same lookup I was using prior? where it was only patching the first record

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Anonymous 

    The correct one should be

    ForAll(
     QuestionGal_edit.AllItems,
     Patch(
     Audit_answers,
     LookUp(Audit_answers, call_reference = Audit_answers[@call_reference]),
     {
     call_reference: reference_edit.Text,
     call_type: Calltype_dropdown_edit.Selected.'Call Type',
     date_of_audit: Audit_Date_edit.SelectedDate,
     BU: BU_dropdown_edit.Selected.Value,
     advisor: Advisor_dropdown_edit.Selected.Advisor_name,
     Question: 'Question-text_edit'.Text,
     Pass_Fail: Pass_dropdown_edit.Selected.Value,
     Feedback: Feedback_dropdown_edit.Selected.Value,
     bulk_audit: Bulk_1.Text,
     Satisfaction: Satisfaction_1.Selected.Value
     }
     )
    )
    



    See if it helps @Anonymous 

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Anonymous 
    No in yours you have this LookUp which always picks the same record from reference_edit.Text that's why it only Patched one record.

    LookUp(Audit_answers, call_reference = reference_edit.Text), ...

     

    In mine I have this LookUp which is scoped to the ForAll record scope in Audit_answers which should work correctly for you:

    LookUp(Audit_answers, call_reference = Audit_answers[@call_reference]), ...
    

     

    See if it helps now @Anonymous 

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Anonymous 

    I checked and I think it's the wrong record scope I gave, try this below instead:

    With(
     { wItems: QuestionGal_edit.AllItems },
     ForAll(
     wItems,
     Patch(
     Audit_answers,
     LookUp(Audit_answers, call_reference = wItems[@call_reference]),
     {
     call_reference: reference_edit.Text,
     call_type: Calltype_dropdown_edit.Selected.'Call Type',
     date_of_audit: Audit_Date_edit.SelectedDate,
     BU: BU_dropdown_edit.Selected.Value,
     advisor: Advisor_dropdown_edit.Selected.Advisor_name,
     Question: 'Question-text_edit'.Text,
     Pass_Fail: Pass_dropdown_edit.Selected.Value,
     Feedback: Feedback_dropdown_edit.Selected.Value,
     bulk_audit: Bulk_1.Text,
     Satisfaction: Satisfaction_1.Selected.Value
     }
     )
     )
    )
    

     

    Now it should work, try with the above @Anonymous .

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard