From 6f02194c23661e92dd540c93000a456171269a62 Mon Sep 17 00:00:00 2001 From: aewing Date: Wed, 7 Jan 2026 07:37:48 +0000 Subject: [PATCH] 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 --- server.ts | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/server.ts b/server.ts index 3520894..d7e5399 100644 --- a/server.ts +++ b/server.ts @@ -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 = {}; + 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 };