cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kosenurm
Post Partisan
Post Partisan

Patch only those selected items (from Gallery)

Hi there,

 

I have a reservations canvas app, whereby the user selects checkboxes to reserve desks, and this patches to a collection called "col_booking". The items in this collection are displayed in a gallery, as a sort of shopping cart as the user selects what they want to reserve. 

 

I now want to patch this to Dataverse, based on what they have selected, which would be displaying in the gallery. 

 

My current patch code:

 

Patch(
    Reservations, Defaults(Reservations),
    {'Booking - Area': Dropdown2.Selected.Value},
    {'Booking - Availability Status': "Reserved"},
    {'Booking - Booked By': User().FullName},
    {'Booking - Booked For': Dropdown6.Selected.Value},
    {'Booking - Reservation Date': dp1.SelectedDate},
    {'Booking - Bank Identifier': ""},
    {'Booking - Booked by Email': User().Email},
    {'Booking - Notify Addresses': Text(ComboBox1.Selected.Mail)},
    {'Desk Reference': ""})

 

What I want to do is, for the "Bank Identifier" patch element, patch only those selected (so only those which are part of the collection) but have each selected item be on individual Dataverse rows.

 

So, if the user selects Bank A, Bank B and Bank C, this would create three Dataverse rows but with Bank Identifier being "Bank A" for one, "Bank B" for the next, "Bank C" for the last etc. All other information remaining the same parameters. 

 

Any ideas please?

 

Thanks, 

K.

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Super User
Super User

Hi @Kosenurm 

 

I assume you have a checkbox on the gallery to define whether selected or not.

  • Filter the gallery - Selected ones
  • Loop through the Gallery
ForAll(Filter(Gallery1.AllItems, Checkbox1.Value = true) As Source,
Patch(
    Reservations, Defaults(Reservations),
    {'Booking - Area': Dropdown2.Selected.Value},
    {'Booking - Availability Status': "Reserved"},
    {'Booking - Booked By': User().FullName},
    {'Booking - Booked For': Dropdown6.Selected.Value},
    {'Booking - Reservation Date': dp1.SelectedDate},
    {'Booking - Bank Identifier': Source.FieldName},
    {'Booking - Booked by Email': User().Email},
    {'Booking - Notify Addresses': Text(ComboBox1.Selected.Mail)},
    {'Desk Reference': ""}
) //Patch
) //Forall

 
Thanks,
Stalin - Learn To Illuminate

View solution in original post

2 REPLIES 2
StalinPonnusamy
Super User
Super User

Hi @Kosenurm 

 

I assume you have a checkbox on the gallery to define whether selected or not.

  • Filter the gallery - Selected ones
  • Loop through the Gallery
ForAll(Filter(Gallery1.AllItems, Checkbox1.Value = true) As Source,
Patch(
    Reservations, Defaults(Reservations),
    {'Booking - Area': Dropdown2.Selected.Value},
    {'Booking - Availability Status': "Reserved"},
    {'Booking - Booked By': User().FullName},
    {'Booking - Booked For': Dropdown6.Selected.Value},
    {'Booking - Reservation Date': dp1.SelectedDate},
    {'Booking - Bank Identifier': Source.FieldName},
    {'Booking - Booked by Email': User().Email},
    {'Booking - Notify Addresses': Text(ComboBox1.Selected.Mail)},
    {'Desk Reference': ""}
) //Patch
) //Forall

 
Thanks,
Stalin - Learn To Illuminate

Thanks for your reply.

 

The gallery only displays those items where the individual checkboxes are selected on the desk-map (this is a deskbooking app), so there are no checkboxes in the gallery itself. 

 

How could I change the code you have provided so that just for anything which is in Gallery1 is patched in a ForAll way?

 

Thanks

K.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,759)