Add checklist items and plum label to Planner tasks

- Add 3 checklist items to new Planner tasks:
  1. Create Voxer Chat
  2. Create Quickbooks
  3. Upload plans
- Add plum label (category6) to tasks
- Checklist and description patched in single API call
- Label added via separate PATCH with proper ETag handling
This commit is contained in:
2026-01-07 07:37:48 +00:00
parent cc52c11bf6
commit 6f02194c23
+29 -2
View File
@@ -472,7 +472,20 @@ async function createPlannerTask({
console.log(`✓ Planner task created in Plan ID: ${planId}`);
// Set the Notes/Description via task details (match the working test script)
// Build checklist object with unique IDs
const checklist: Record<string, { '@odata.type': string; title: string; isChecked: boolean; orderHint: string }> = {};
const checklistItems = ['Create Voxer Chat', 'Create Quickbooks', 'Upload plans'];
checklistItems.forEach((item, index) => {
const itemId = `checklist_${Date.now()}_${index}`;
checklist[itemId] = {
'@odata.type': 'microsoft.graph.plannerChecklistItem',
title: item,
isChecked: false,
orderHint: ` ${index}!`,
};
});
// Set the Notes/Description AND checklist via task details
const taskDetails = await client.api(`/planner/tasks/${newTask.id}/details`).get();
const detailsEtag = taskDetails['@odata.etag'];
console.log(`[Planner] Task created ${newTask.id}, fetched details ETag: ${detailsEtag}`);
@@ -481,8 +494,22 @@ async function createPlannerTask({
.header('If-Match', detailsEtag)
.patch({
description: 'Move the new folder to the correct Job Pages folder.',
checklist: checklist,
});
console.log(`[Planner] Successfully patched description`);
console.log(`[Planner] Successfully patched description and added ${checklistItems.length} checklist items`);
// Add "plum" label (category6) to task
const taskForLabel = await client.api(`/planner/tasks/${newTask.id}`).get();
const taskEtag = taskForLabel['@odata.etag'];
await client
.api(`/planner/tasks/${newTask.id}`)
.header('If-Match', taskEtag)
.patch({
appliedCategories: {
category6: true,
},
});
console.log(`[Planner] Added plum label to task`);
console.log(`✓ Planner task created: "${title}" assigned to ${assigneeName}`);
return { success: true, taskId: newTask.id, title };