It is my intention to create a second task with the "error" items.
here is the update function:
With(
{
desc: Split(
DescriptionTextInput.Value,
Char(10)
),
bool: StartsWith(
DescriptionTextInput.Value,
"Record"
)
},
ForAll(
Sequence(
CountRows(desc) - bool,
If(
bool,
2,
1
)
),
Planner.UpdateTaskDetailsV2(
NewTask.id,
{
description: CommentsTextInput.Value,
checklist: {
id: ThisRecord.Value,
isChecked: false,
title: Index(
desc,
ThisRecord.Value
).Value
}
}
)
)
),
If Planner.CreateTaskV4 errors out due to "MaximumChecklistItemsOnTask", how would I catch this and create the new task (and update the 'errortask')
You can loop the else statement and drop the first 20 columns and continue the process.
Remove(ColChecklistItems, FirstN(ColChecklistItems,20))
If the collection has more than 20 items, you can push first 20 items, then remove those items, and push 20 again.
Cheers!
I used your input and prompted for code. Seems implementable. I will try the IF statement with <20 or 20-40 as the options. If there were more than 40 I would need a more complex formula. But, here I have something that might be viable.
// Split the checklist items
ClearCollect(ColChecklistItems, Split(DescriptionTextInput.Value, Char(10)));
// Create the first task and add up to 20 checklist items to it
Set(NewTask, Planner.CreateTaskV4({...}));
ForAll(
FirstN(ColChecklistItems, 20),
Planner.UpdateTaskDetailsV2(
NewTask.id,
{
description: CommentsTextInput,
checklist: {
id: Value,
isChecked: false,
title: Index,
desc: Value
}
}
)
);
// If there are more than 20 items, create a second task and add the remaining items to it
If(
CountRows(ColChecklistItems) > 20,
(
Set(
SecondTask,
Planner.CreateTaskV4(
{
title: NewTask.title & " 2",
planId: NewTask.planId,
bucketId: NewTask.bucketId,
// ... any other properties you need to set
}
)
);
ForAll(
LastN(ColChecklistItems, CountRows(ColChecklistItems) - 20),
Planner.UpdateTaskDetailsV2(
SecondTask.id,
{
description: CommentsTextInput,
checklist: {
id: Value,
isChecked: false,
title: Index,
desc: Value
}
}
)
)
)
);
In you collection of items, add row numbers for each item.
Add a condition for creating tasks, you can add an if statement to check if CountRows in you collection is more than 20.
With the if condition, send the planner tasks in batches of 20 so that it doesn't exceed the limit.
You can reference the limits from here: https://learn.microsoft.com/en-us/office365/planner/planner-limits
Cheers!
WarrenBelz
146,645
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional