web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Pages - Design & Build
Unanswered

Having trouble storing a collection of scheduled assigned content of 6 weeks to SP list single row

(0) ShareShare
ReportReport
Posted on by
I require some help storing a collection which stores schedule of content assignment for 6 weeks to SP list single row. The Schedule runs from Week 1 Monday to Week 6 Friday skipping weekends.
 
First i tried storing the data for 5 days with the following code, which did the job. This was set on the onchange of the date picker.

// 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
 
// 1) Compute Monday of the week containing the selected date
Set(
    varWeekStart,
    DateAdd(
        dpWeek.SelectedDate,
        -(Weekday(dpWeek.SelectedDate, StartOfWeek.Monday) - 1),
        TimeUnit.Days
    )
);
 
// 2) Build 6 weeks × 5 days (strict Mon–Fri blocks)
//    - Week: "W1" .. "W6"
//    - DayDate: Mon..Fri, skipping weekends by adding +2 each 5 days
//    - DayName: "Monday"..."Friday"
//    - SelectedComm: placeholder; your UI replaces per day
ClearCollect(
    colWeek,
    ForAll(
        Sequence(30) As S,
        {
            Week: "W" & Text( RoundDown( (S.Value - 1) / 5, 0 ) + 1 ),
 
            DayDate:
                DateAdd(
                    varWeekStart,
                    (S.Value - 1) + 2 * RoundDown( (S.Value - 1) / 5, 0 ),
                    TimeUnit.Days
                ),
 
            DayName:
                Text(
                    DateAdd(
                        varWeekStart,
                        (S.Value - 1) + 2 * RoundDown( (S.Value - 1) / 5, 0 ),
                        TimeUnit.Days
                    ),
                    "[$-en-US]dddd"
                ),
 
            SelectedComm: "_BlankComm"
        }
    )
);


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.
Categories:
tc2.PNG
tc1.PNG

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

I have the same question (0)
  • Michael E. Gernaey Profile Picture
    51,550 Super User 2025 Season 2 on at
    Having trouble storing a collection of scheduled assigned content of 6 weeks to SP list single row
     
    Please paste in your pictures instance.
     
    Also, please clarify what this means

    Having trouble storing a collection of scheduled assigned content of 6 weeks to SP list single row

     
    Please do not use code etc to explain, use bullet points to describe exactly what you want, then if you want to show pictures so it makes sense is great.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 50 Super User 2025 Season 2

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 38 Super User 2025 Season 2

#3
Jerry-IN Profile Picture

Jerry-IN 30

Last 30 days Overall leaderboard

Featured topics