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
Solved! Go to Solution.
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/...
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/...
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
User | Count |
---|---|
204 | |
97 | |
60 | |
51 | |
46 |
User | Count |
---|---|
255 | |
158 | |
87 | |
79 | |
59 |