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 / how to patch gallery i...
Power Apps
Answered

how to patch gallery items based on certain ID

(0) ShareShare
ReportReport
Posted on by 57

Hello folks,

I am struggling to patch gallery items which is filtered on certain ID.

 

Use Case: there are one form (above in pic) and one gallery whose DBs are different. i just want to update the changes in both  area. i can make it for form but cannot patch updates for certain ID for Gallery.

The Code;

 

Filter(colDeneme2,refID=Value(DataCardValue27.Text));

ForAll(
 colDeneme2,
 Patch(
 DenemeFormDetay,
 {
 Proses: ddproses2.Selected,
 'İş Akışı': txtIsakıs2.Text,
 Sorumlu: ddSorumlu2.Selected,
 Termin: ddTermin2.SelectedDate
 }
 )
);
Patch(
 DenemeFormAna,
 {ID: Value(DataCardValue27.Text)},
 Form3.Updates
);
UpdateItem.Run(DataCardValue27.Text);

 

 

Mythran_0-1659020009021.png

In DB side, the item which i want to patch,  is being recorded in separate row multiple times (Only the last row) not not getting "refID" value.

 

Mythran_1-1659020379515.png

 

how can make this happen?

 

Categories:
I have the same question (0)
  • NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    Hi,

    While updating item you need to pass record in Patch function.
    Assuming there is 1:1 ratio. You can try using below formula - 

    Patch(
    DenemeFormDetay, 

    LookUp(colDeneme2,refID=Value(DataCardValue27.Text)),
    {
    Proses: ddproses2.Selected,
    'İş Akışı': txtIsakıs2.Text,
    Sorumlu: ddSorumlu2.Selected,
    Termin: ddTermin2.SelectedDate
    }
    )

  • Mythran Profile Picture
    57 on at

    Hello @NandiniBhagya20 

     

    there are more than one record with same refID. İn that case would that same formula work ?

  • NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    In that case you can try using below formula:
    ClearCollect(colDataToLoop,Filter(colDeneme2,refID=Value(DataCardValue27.Text)));
    ForAll(colDataToLoop,

    Patch(
    DenemeFormDetay

    LookUp(colDeneme2,refID=ID),
    {
    Proses: ddproses2.Selected,
    'İş Akışı': txtIsakıs2.Text,
    Sorumlu: ddSorumlu2.Selected,
    Termin: ddTermin2.SelectedDate
    }
    )
    )

  • Mythran Profile Picture
    57 on at

    @NandiniBhagya20 

     

    With that formula i can only change first item of gallery. however second item remained same.

     

    Mythran_0-1659083640583.png

     

  • Mythran Profile Picture
    57 on at

    Hello Folks,

    is there any other solution?

  • Mythran Profile Picture
    57 on at

    Hello Folks,

     

    the latest situation i can only patch latest item. with the code i share below. why could that happen i didn't figure out. could you please help me?

     

    Gallery onSelect:

    ClearCollect(colDeneme2,ThisItem,{Proses:ddproses2.Selected, 'İş Akışı':txtIsakıs2.Text, Sorumlu:ddSorumlu2.Selected,Termin:ddTermin2.SelectedDate })

     

    Save onSelect

     

    Collect(colDatatoLoop,Filter(colDeneme2,refID=Value(DataCardValue27.Text)));
    
    ForAll(
     colDatatoLoop,
     Patch(
     DenemeFormDetay,
     LookUp(colDeneme2,ID=Value(lblID.Text)),
     {
     Proses: ddproses2.Selected,
     'İş Akışı': txtIsakıs2.Text,
     Sorumlu: ddSorumlu2.Selected,
     Termin: ddTermin2.SelectedDate
     }
     )
    );
    Clear(colDatatoLoop);
    Patch(
     DenemeFormAna,
     {ID: Value(DataCardValue27.Text)},
     Form3.Updates
    );
    UpdateItem.Run(DataCardValue27.Text);

     

     

    Mythran_1-1659101243592.png

     

     

    Mythran_0-1659101169395.png

     

  • NandiniBhagya20 Profile Picture
    4,667 Super User 2024 Season 1 on at

    Hi,
    With Gallery onselect formula,
    Instead of using ClearCollect use Collect and Clear the collection on screen visible. 
    OnScreen Visible property: 
    Gallery onselect: Clear(colDeneme2)

    Collect(colDeneme2,ThisItem,{Proses:ddproses2.Selected, 'İş Akışı':txtIsakıs2.Text, Sorumlu:ddSorumlu2.Selected,Termin:ddTermin2.SelectedDate })
    You should collect either ThisItem or this object : {Proses:ddproses2.Selected, 'İş Akışı':txtIsakıs2.Text, Sorumlu:ddSorumlu2.Selected,Termin:ddTermin2.SelectedDate }
    Collecting both will create 2 entries
    If you want to update you collection with the object properties than you can use below function:

    Collect(colDeneme2,ThisItem); UpdateIf(colDeneme2, <condition>, {<columns to update with value for ex Title: "test">})

  • Mythran Profile Picture
    57 on at

    @NandiniBhagya20 

     

    Hello, it doesn't change anything. the problem is in "ForAll" formula. because i can patch it but only last record. it's really frustrating 

  • MuFeR Profile Picture
    31 on at

    I think this suggestion can still work just by replacing the LookUp part with ThisRecord since you already got all the records you need to patch. By doing a LookUp you're always getting the first record in your loop and patch the same thing.

     

    ClearCollect(colDataToLoop,Filter(colDeneme2,refID=Value(DataCardValue27.Text)));
    ForAll(colDataToLoop,

    Patch(
    DenemeFormDetay

    ThisRecord,
    {
    Proses: ddproses2.Selected,
    'İş Akışı': txtIsakıs2.Text,
    Sorumlu: ddSorumlu2.Selected,
    Termin: ddTermin2.SelectedDate
    }
    )
    )

  • Mythran Profile Picture
    57 on at

    hello @MuFeR 

     

    i changed with "ThisRecord" however this time all items became identical and take the values of last item.

     

    Mythran_0-1659241485495.png

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard