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 Patch Multiple ...
Power Apps
Answered

ForAll Patch Multiple Tables for Multiple users

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all, 

I built an hour registration app with three entities in CDS which look more or less like this: 

1.
Name: TimeEntries (multiple records per employee per week)
Scheme: Week, Project, Employee, WeekStart, Mon, Tue, Wed, Thurs, Fri, Sa, Sun
ForAll & Patch Logic: 
Forall(gallery.AllItems,
IfIsBlank(TimeEntriesID; //If record is new 
Patch(TimeEntries;
Defaults(TimeEntries);
{...}
)
;// Else Update existing record 
Patch(TimeEntries;
{TimeEntriesID:TimeEntriesID};
{...}
)

2.
Name: TimeEntryPerDay/Employee (multiple records per employee per day) 
Scheme: Date (weekStart+x), Project, Employee, Hours, ReftoTimeEntries
ForAll & Patch logic: Here I have 7  Forall/Patch(Defaults(TimeEntryPerDay({...})) statements each patching a record for 1 day of the week (weekStart+x)... I also patch along the reference to the specific TimeEntries week record in CDS so that updates to the Hour/Project field can be done using a calculated reference field. 

3.
Name: TimeEntryRollup (one record per employee per week) 
Scheme: Week Employee TotalHours
Patch logic: Separate patch statement updating the Total hours an employee has worked in one week


So this all works, probably could do it more efficient here and there but OK. 

Now I want to add functionality where users can enter hours for their team at the same time. I would supply them with a list control where they can select for whom in their team they wish to enter times. 

In my set-up this would require me to create an additional record per user in all three tables where only the username is different. So if three users are selected, three records are created with the same project/hour values etc but different user. If one just one, etc... 

I am kind of stuck how to manage this efficiently in the patch logic. Would it be possible in the same statement? Any suggestions? 

Thanks in advance

Categories:
  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Solved

    Using logic described in below post I created an selectedUser collection and crossjoined that with the input records

     https://powerusers.microsoft.com/t5/Building-Power-Apps/Cross-join-or-Cartesian-Join-of-collections/td-p/517720


  • Pablo Carceller Profile Picture
    Microsoft Employee on at

    Thank you for the information @Anonymous ! Really can help others

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

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard