// Compute Monday
Set(
varWeekStart,
DateAdd(
dpWeek.SelectedDate,
-(Weekday(dpWeek.SelectedDate, StartOfWeek.Monday) - 1),
TimeUnit.Days
)
);
// Rebuild Mon–Fri with SelectedComm placeholder
ClearCollect(
colWeek,
{ DayName: "Monday", DayDate: varWeekStart, SelectedComm: "_BlankComm" },
{ DayName: "Tuesday", DayDate: DateAdd(varWeekStart, 1, TimeUnit.Days), SelectedComm: "_BlankComm" },
{ DayName: "Wednesday", DayDate: DateAdd(varWeekStart, 2, TimeUnit.Days), SelectedComm: "_BlankComm" },
{ DayName: "Thursday", DayDate: DateAdd(varWeekStart, 3, TimeUnit.Days), SelectedComm: "_BlankComm" },
{ DayName: "Friday", DayDate: DateAdd(varWeekStart, 4, TimeUnit.Days), SelectedComm: "_BlankComm" }
);
Updated for 30 Days
Submit button logic for 5 days
// READ the 5 IDs from the collection
Set(varMonId, LookUp(colWeek, DayName="Monday").SelectedComm);
Set(varTueId, LookUp(colWeek, DayName="Tuesday").SelectedComm);
Set(varWedId, LookUp(colWeek, DayName="Wednesday").SelectedComm);
Set(varThuId, LookUp(colWeek, DayName="Thursday").SelectedComm);
Set(varFriId, LookUp(colWeek, DayName="Friday").SelectedComm);
// CREATE the row in CommSchedule, storing IDs as TEXT in W1Monday..W1Friday
Patch(
'CommSchedule 2',
Defaults('CommSchedule 2'),
{
Title: "Week of " & Text(varWeekStart, "dd-mmm-yyyy"),
StartDate: varWeekStart,
W1Monday: If(!IsBlank(varMonId), Text(varMonId), Blank()),
W1Tuesday: If(!IsBlank(varTueId), Text(varTueId), Blank()),
W1Wednesday: If(!IsBlank(varWedId), Text(varWedId), Blank()),
W1Thursday: If(!IsBlank(varThuId), Text(varThuId), Blank()),
W1Friday: If(!IsBlank(varFriId), Text(varFriId), Blank())
}
);
Notify("Week saved.", NotificationType.Success);
I have attempted at the logic for 30 days to be written in a single row with the below but instead it stored each week as a new record.
// Create 6 rows in 'CommSchedule 2', one per week (W1..W6),
// populating W1Monday..W1Friday fields for that row.
ForAll(
    Sequence(6) As W,
    With(
        {
            wkLabel: "W" & Text(W.Value),
            // Get the Monday (or the earliest day in that week as fallback)
            wkStart:
                With(
                    {
                        monRec: LookUp(
                            colWeek,
                            Week = "W" & Text(W.Value) && Weekday(DayDate, StartOfWeek.Monday) = 1
                        ),
                        firstRec: First(
                            SortByColumns(
                                Filter(colWeek, Week = "W" & Text(W.Value)),
                                "DayDate",
                                Ascending
                            )
                        )
                    },
                    Coalesce(monRec.DayDate, firstRec.DayDate)
                ),
            // Pull each weekday's SelectedComm for that week
            monId: With({ r: LookUp(colWeek, Week = "W" & Text(W.Value) && Weekday(DayDate, StartOfWeek.Monday) = 1) }, r.SelectedComm),
            tueId: With({ r: LookUp(colWeek, Week = "W" & Text(W.Value) && Weekday(DayDate, StartOfWeek.Monday) = 2) }, r.SelectedComm),
            wedId: With({ r: LookUp(colWeek, Week = "W" & Text(W.Value) && Weekday(DayDate, StartOfWeek.Monday) = 3) }, r.SelectedComm),
            thuId: With({ r: LookUp(colWeek, Week = "W" & Text(W.Value) && Weekday(DayDate, StartOfWeek.Monday) = 4) }, r.SelectedComm),
            friId: With({ r: LookUp(colWeek, Week = "W" & Text(W.Value) && Weekday(DayDate, StartOfWeek.Monday) = 5) }, r.SelectedComm)
        },
        Patch(
            'CommSchedule 2',
            Defaults('CommSchedule 2'),
            {
                Title: wkLabel & " — Week of " & Text(wkStart, "dd-mmm-yyyy"),
                StartDate: wkStart,
                // Fill per-week fields (your list has W1Monday..W1Friday only)
                W1Monday:    If(IsBlank(monId) || monId = "_BlankComm", Blank(), Text(monId)),
                W1Tuesday:   If(IsBlank(tueId) || tueId = "_BlankComm", Blank(), Text(tueId)),
                W1Wednesday: If(IsBlank(wedId) || wedId = "_BlankComm", Blank(), Text(wedId)),
                W1Thursday:  If(IsBlank(thuId) || thuId = "_BlankComm", Blank(), Text(thuId)),
                W1Friday:    If(IsBlank(friId) || friId = "_BlankComm", Blank(), Text(friId))
            }
        )
    )
);
Notify("6 weekly rows saved.", NotificationType.Success);
Please guide me how to solve this. The next step after this would be for a flow to read this from the list and schedule mail the assigned content.
		

Report
 All responses (
 Answers (