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 built up a fora...
Power Apps
Unanswered

How to built up a forall(patch) for a dynamic request

(0) ShareShare
ReportReport
Posted on by 20

Hi there,

 

I am trying to build up an availability calendar for my team, and I would like to have a feature which allows users to set the availability for the user for the weekdays throughout the years. 

 

 

ForAll(
 RenameColumns(
 Filter(
 _Availability,
//here is the problematic part, this is statically set
 Weekday(day_of_year) = 3 
 ),
 "ID",
 "SID"
 ),
 Patch(
 _Availability,
 LookUp(
 _Availability,
 ID = SID
 ),
 {
 All_Day_Available: false,
 Partially_Available: false,
 Unavailable: true
 }
 )
)

 

 

 

Users may request multiple days to be changed but I could not figure out how to set the filter query dynamically. The selected days are coming from a gallery with checkboxes. 

 

Thanks in advance.

Categories:
I have the same question (0)
  • ResatCanerBas Profile Picture
    20 on at

    Here is my own resolution 

    //Days of the week selection, first prepare the collection
    If(
     !IsEmpty(__Selected_Days),
     Clear(__Selected_Days)
    );
    // set the collection with IDs for each day
    If(
     LookUp(
     __Days_of_week,
     _day = 1,
     isChoosen
     ),
     Collect(
     __Selected_Days,
     Filter(
     _Availability,
     day_of_year >= CC_Date_Pick_1.SelectedDate,
     Weekday(day_of_year) = 1
     ).ID
     )
    );
    If(
     LookUp(
     __Days_of_week,
     _day = 2,
     isChoosen
     ),
     Collect(
     __Selected_Days,
     Filter(
     _Availability,
     day_of_year >= CC_Date_Pick_1.SelectedDate,
     Weekday(day_of_year) = 2
     ).ID
     )
    );
    If(
     LookUp(
     __Days_of_week,
     _day = 3,
     isChoosen
     ),
     Collect(
     __Selected_Days,
     Filter(
     _Availability,
     day_of_year >= CC_Date_Pick_1.SelectedDate,
     Weekday(day_of_year) = 3
     ).ID
     )
    );
    If(
     LookUp(
     __Days_of_week,
     _day = 4,
     isChoosen
     ),
     Collect(
     __Selected_Days,
     Filter(
     _Availability,
     day_of_year >= CC_Date_Pick_1.SelectedDate,
     Weekday(day_of_year) = 4
     ).ID
     )
    );
    If(
     LookUp(
     __Days_of_week,
     _day = 5,
     isChoosen
     ),
     Collect(
     __Selected_Days,
     Filter(
     _Availability,
     day_of_year >= CC_Date_Pick_1.SelectedDate,
     Weekday(day_of_year) = 5
     ).ID
     )
    );
    If(
     LookUp(
     __Days_of_week,
     _day = 6,
     isChoosen
     ),
     Collect(
     __Selected_Days,
     Filter(
     _Availability,
     day_of_year >= CC_Date_Pick_1.SelectedDate,
     Weekday(day_of_year) = 6
     ).ID
     )
    );
    If(
     LookUp(
     __Days_of_week,
     _day = 7,
     isChoosen
     ),
     Collect(
     __Selected_Days,
     Filter(
     _Availability,
     day_of_year >= CC_Date_Pick_1.SelectedDate,
     Weekday(day_of_year) = 7
     ).ID
     )
    );
    //Patch the Collection
    ForAll(
     RenameColumns(
     __Selected_Days,
     "ID",
     "SID"
     ),
     Patch(
     _Availability,
     LookUp(
     _Availability,
     ID = SID
     ),
     {
     All_Day_Available: false,
     Partially_Available: false,
     Unavailable: true
     }
     )
    );
    

    I created a collection and collected all 7 cases where selected and applied patch on them.  

  • Rohit Sharma354 Profile Picture
    Microsoft Employee on at

    Hello,

     

    I don't have an alternate solution, but your approach seems to be a good option. Let's see if any other community user has any other suggestions.

     

     

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

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 483

#2
WarrenBelz Profile Picture

WarrenBelz 399 Most Valuable Professional

#3
11manish Profile Picture

11manish 327

Last 30 days Overall leaderboard