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 / ForAll in collection
Power Apps
Answered

ForAll in collection

(0) ShareShare
ReportReport
Posted on by 802

Hi there,

 

I am working on a deskbooking canvas app, and am trying to implement functionality where users can book more than one desk at one time. 

 

To do this, they select the desk number they want in the below first drop down. This then looksup to the Dataverse table to update the end dropdown to Unavailable if already booked, or Available if free. Here is the UI...

 

mutli desk.PNG

 

On each of the 'Select desk' dropdowns, I have the following for OnChange and OnSelect...

 

OnChange...

 

 

 

 

 

If(Multi4DeskStatus_1.Text = "Available", Remove(Car4FECol, {id: "deskone4FE"}, {desk: Desk1.Selected.Value}, {date: DateDesk1.SelectedDate}, {floor: MultiFloor4_1.SelectedText}, {area: MultiArea4_1.SelectedText}, {reservedforname: User().FullName}, {reservedforemail: User().Email}, {site: "Cardiff"}, {bookedby: User().FullName}));

If(Multi4DeskStatus_1.Text = "Available", Collect(Car4FECol, {id: "deskone4FE"}, {desk: Desk1.Selected.Value}, {date: DateDesk1.SelectedDate}, {floor: MultiFloor4_1.SelectedText}, {area: MultiArea4_1.SelectedText}, {reservedforname: User().FullName}, {reservedforemail: User().Email}, {site: "Cardiff"}, {bookedby: User().FullName}));

 

 

 

 

 

OnSelect...

 

 

 

 

 

If(Multi4DeskStatus_1.Text = "Available", Remove(Car4FECol, {id: "deskone4FE"}, {desk: Desk1.Selected.Value}, {date: DateDesk1.SelectedDate}, {floor: MultiFloor4_1.SelectedText}, {area: MultiArea4_1.SelectedText}, {reservedforname: User().FullName}, {reservedforemail: User().Email}, {site: "Cardiff"}, {bookedby: User().FullName}));

If(Multi4DeskStatus_1.Text = "Available", Collect(Car4FECol, {id: "deskone4FE"}, {desk: Desk1.Selected.Value}, {date: DateDesk1.SelectedDate}, {floor: MultiFloor4_1.SelectedText}, {area: MultiArea4_1.SelectedText}, {reservedforname: User().FullName}, {reservedforemail: User().Email}, {site: "Cardiff"}, {bookedby: User().FullName}));

 

 

 

 

 

Of course, each of the dropdowns for each of the seven desks increments the "_1" values each time, and 'id' changes to 'desktwo4FE', 'deskthree4FE' etc etc. 

 

The effect of the above to be, if the user selects or changes their desk selection, remove whatever is in the collection for that desk already, and collect the new selection, but only if the desk is Available.

 

What I am then trying to do is Patch all of these in the collection to my Dataverse table.

 

To do this, I am trying this OnSelect of the Submit button is...

 

 

 

 

 

ForAll(Car4FECol, Patch(Car_Desk_Reservations, Defaults(Car_Desk_Reservations),
 {'Car Desk Reservation Date': date},
 {'Car Floor Number': floor.Value},
 {'Car Floor Area': area.Value},
 {'Car Desk Availability Status': "Reserved"},
 {'Car Desk Booked By': bookedby},
 {'Car Desk Reserved For': reservedforname},
 {'Car Desk Reserved For Email': reservedforemail},
 {Location: "Cardiff"},
 {'Desk Reference': desk},
 {'Car Pass Status': "Yes"}));

 

 

 

 

 

but this is erroring. The Dataverse table's mandatory column is 'Desk Reference', and it is erroring saying that this field is required... but I am putting the collection value here as part of the ForAll.  I have tried wrapping in a Text command - so,  {'Desk Reference': Text(desk)}, and this starts to patch (takes a very long time), but only patches the Text "" fields, a lot of blank rows with just the desk reference, but nothing from the collection??

 

Please can someone advise me where I might be going wrong here?

 

Thanks

K.

Categories:
I have the same question (0)
  • PowerGirl Profile Picture
    130 on at

    Hi Kosenurm,

    Did you checked the content of your Car4FECol ? are the values showing what you expect? (you can do this in menu View, Collections and select your collection)

    Is your 'Desk reference' a text column or it has specific allowed values (like in the Desk1.Selected.Value)? Maybe what it is expecting is the specific allowed value and "desk" is not matching any of them?

    If you are creating new records every time, have you tried to use the option Collect instead of For All and Patch? You would need to rename the columns to match the dataverse table column names.

    Collect(Car_Desk_Reservations, RenameColumns(Car4FECol,"date","Car Desk Reservation Date",....) 

     

    just some ideas, I hope they help 

     

  • Kosenurm Profile Picture
    802 on at

    Thanks for your reply. 

     

    No, I have added a temporary gallery to see the items coming into the Collection and they are not what I expect. 

     

    I have changed the OnSelect of the drop down to:

     

    If(Multi4DeskStatus_1.Text = "Available", Collect(Car4FECol, {id: "deskone4FE"}, {desk: Desk1.Selected.Value}, {date: DateDesk1.SelectedDate}, {floor: MultiFloor4_1.SelectedText}, {area: MultiArea4_1.SelectedText}, {reservedforname: User().FullName}, {reservedforemail: User().Email}, {site: "Cardiff"}, {bookedby: User().FullName}));

     

    And changed the OnChange to...

     

    If(Multi4DeskStatus_1.Text = "Available", Update(Car4FECol, {id: "deskone4FE"}, {desk: Desk1.Selected.Value}))

     

    The first selection I make in the Desk dropdown adds the Desk number to the gallery, but when I then change the dropdown to another desk, it doesn't update?? Also, only the desk number seems to come through to the gallery, even though there are labels in there for the other collection elements (e.g. ThisItem.bookedby etc).

     

    😞

     

    Thanks

    K.

  • Verified answer
    Kosenurm Profile Picture
    802 on at

    The desk reference in the Dataverse table is just text, in the dropdown it is a series of hardcoded text values.

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
Vish WR Profile Picture

Vish WR 914

#2
11manish Profile Picture

11manish 617

#3
Valantis Profile Picture

Valantis 598

Last 30 days Overall leaderboard