How to create a role task by code in Episerver
After failing duplicating the ParallelApproval Workflow I looked into creating a task by code in the project instead. Didn't find much documentation online so here's my initial Proof of Concept to fill the gap.
This will create a task from the current user and assign it to all users with the WebAdmins role. An e-mail will go out to all users in the role and when one of them change the status an e-mail will go back to the creator.
using EPiServer.Personalization; .. Task currentTask = new Task(); currentTask.Subject = "Test"; currentTask.Description = "Some more text"; currentTask.AssignedTo = "WebAdmins"; currentTask.AssignedIsRole = true; currentTask.DueDate = DateTime.Now.AddDays(1); // Would be better to somehow fetch PlugInID // by it's name "EPiServer.UI.Util.PlugIns.ViewTask" // instead of this: currentTask.PlugInID = 144; currentTask.Save();
Tested using EPiServer CMS 5 R2 SP2.
Published Monday 14 December 2009 16:41 and tagged with these categories: Episerver, Development