create_work_item
Create new work items in DevOps Plan systems by specifying title, description, type, application, and project to track development tasks.
Instructions
Creates a new work item in Plan
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| component | No | An optional component name if any are available in the project, this is not required. | |
| title | Yes | Title of the work item | |
| description | Yes | Description of the work item | |
| workItemType | Yes | Type of the work item from the list of available work item types | |
| application | Yes | Name of the application | |
| projectName | Yes | Name of the project |
Implementation Reference
- old-server.js:356-420 (handler)The tool definition and handler logic for "create_work_item".
server.tool( "create_work_item", "Creates a new work item in Plan", { component: z.string().optional().describe("An optional component name if any are available in the project, this is not required."), title: z.string().describe("Title of the work item"), description: z.string().describe("Description of the work item"), workItemType: z.string().describe("Type of the work item from the list of available work item types"), application: z.string().describe("Name of the application"), projectId: z.string().describe("ID of the project") }, async ({component, title, description, workItemType, application, projectId }) => { try { if (!globalCookies) { globalCookies = await getCookiesFromServer(serverURL); if (!globalCookies) { console.error("Failed to retrieve cookies from server."); return { error: "Failed to retrieve cookies." }; } console.log("Received Cookies:", globalCookies); } else { console.log("Reusing Stored Cookies:", globalCookies); } let bodyJSON = JSON.parse(createWorkItemBody); if(component !== undefined){ // Use empty string if not provided bodyJSON.fields[0].value = component || ""; bodyJSON.fields[0].valueAsList[0] = component || ""; } bodyJSON.fields[2].value = projectId; bodyJSON.fields[2].valueAsList[0] = projectId; bodyJSON.fields[4].value = title; bodyJSON.fields[4].valueAsList[0] = title; bodyJSON.fields[5].value = description; bodyJSON.fields[5].valueAsList[0] = description; bodyJSON.fields[6].value = workItemType; bodyJSON.fields[6].valueAsList[0] = workItemType; let body = JSON.stringify(bodyJSON); const response = await fetch(`${serverURL}/ccmweb/rest/repos/${teamspaceID}/databases/${application}/records/WorkItem/?operation=Commit&useDbid=false`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': `Basic ${personal_access_token_string}`, 'Cookie': globalCookies }, body: body }); const data = await response.json(); if (data.viewURL) { return { content: [{ type: 'text', text: `Work item created successfully. View it at: ${serverURL}/#${data.viewURL}` }] }; } else { throw new Error("Failed to create work item"); } } catch (e) { return { content: [{ type: 'text', text: `Error creating work item: ${e.message}` }] }; } } ); - old-server.js:799-938 (schema)The JSON template used for creating a work item.
const createWorkItemBody = ` { "dbId": "33554505", "displayName": "string", "entityDefName": "Project", "fields": [ { "name": "Component", "value": "", "valueStatus": "HAS_VALUE", "validationStatus": "_KNOWN_VALID", "requiredness": "READONLY", "requirednessForUser": "READONLY", "type": "REFERENCE", "valueAsList": [ "" ], "messageText": "", "maxLength": 0 }, { "name": "dbid", "value": "33554505", "valueStatus": "HAS_VALUE", "validationStatus": "_KNOWN_VALID", "requiredness": "READONLY", "requirednessForUser": "READONLY", "type": "DBID", "valueAsList": [ "33554505" ], "messageText": "", "maxLength": 0 }, { "name": "Project", "value": "Devops Code", "valueStatus": "HAS_VALUE", "validationStatus": "_KNOWN_VALID", "requiredness": "READONLY", "requirednessForUser": "READONLY", "type": "REFERENCE", "valueAsList": [ "Devops Code" ], "messageText": "", "maxLength": 0 }, { "name": "record_type", "value": "WorkItem", "valueStatus": "HAS_VALUE", "validationStatus": "_KNOWN_VALID", "requiredness": "READONLY", "requirednessForUser": "READONLY", "type": "RECORDTYPE", "valueAsList": [ "WorkItem" ], "messageText": "", "maxLength": 30 }, { "name": "Title", "value": "Plan Item", "valueStatus": "HAS_VALUE", "validationStatus": "_KNOWN_VALID", "requiredness": "READONLY", "requirednessForUser": "READONLY", "type": "SHORT_STRING", "valueAsList": [ "Plan Item" ], "messageText": "", "maxLength": 254 }, { "name": "Description", "value": "Plan Item", "valueStatus": "HAS_VALUE", "validationStatus": "_KNOWN_VALID", "requiredness": "READONLY", "requirednessForUser": "READONLY", "type": "MULTILINE_STRING", "valueAsList": [ "Plan Item" ], "messageText": "", "maxLength": 0 }, { "name": "WIType", "value": "Task", "valueStatus": "HAS_VALUE", "validationStatus": "_KNOWN_VALID", "requiredness": "READONLY", "requirednessForUser": "READONLY", "type": "SHORT_STRING", "valueAsList": [ "Task" ], "messageText": "", "maxLength": 254 } ], "legalActions": [ { "actionName": "Submit", "formDefName": "Defect_Base_Submit" } ], "isEditable": true, "isDuplicate": true, "original": { "dbId": "33554524", "displayName": "string", "entityDefName": "Project", "viewURL": "string" }, "isOriginal": true, "hasDuplicates": true, "errorMessage": "string", "duplicates": [ { "child": { "dbId": "33554524", "displayName": "string", "entityDefName": "Project", "viewURL": "string" }, "parent": { "dbId": "33554524", "displayName": "string", "entityDefName": "Project", "viewURL": "string" } } ], "viewURL": "string" }