Thursday, March 13, 2008

MOSS VisualStudio Workflow create a task in the task list

To create a task in the assigend task list of the workflow do the following:

// get the assigned task list of the workflow
SPList taskList = workflowProperties.TaskList;

// create the task
SPListItem task = taskList.Items.Add(documentFolder.Folder.ServerRelativeUrl, SPFileSystemObjectType.File);

// set properties
task["Title"] = "title";
task["Assigned To"] = "user name";
task["Description"] = "task description";

// store the task

task.Update();

No comments: