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

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
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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