Creating several tasks inside single workflow
-
27 April 2011 8:15
I try to do it just by using code activity:
private void codeActivity1_ExecuteCode(object sender, EventArgs e) { foreach (SPFieldUserValue performer2 in Performers2_Collection) { try { CreateTask CreateNewTask = new CreateTask(); SPListItem myitem = workflowProperties.Item; CreateNewTask.TaskId = Guid.NewGuid(); CreateNewTask.TaskProperties = new SPWorkflowTaskProperties(); CreateNewTask.TaskProperties.TaskType = 0; CreateNewTask.TaskProperties.Title = string.Format("APPROVAL REQUIRED: {0}", "_seminarTitle"); CreateNewTask.TaskProperties.AssignedTo = performer2.User.LoginName; CreateNewTask.TaskProperties.SendEmailNotification = true; CreateNewTask.TaskProperties.ExtendedProperties["OriginatorUser"] = workflowProperties.OriginatorUser.LoginName; } catch { } }
But none of tasks are created (
What should i do with CreateTask object to really create task?
Semua Balasan
-
28 April 2011 5:08Try calling the Execute method...
-
28 April 2011 11:50
I did the following screencasts to show how to do both multiple and parallel tasks in workflows.
Scot
Author, Professional Business Connectivity Services
Author, Inside SharePoint 2010 Blog, www.shillier.com
Twitter, @ScotHillier
SharePoint Trainer, Critical Path Training- Ditandai sebagai Jawaban oleh e v e r n i t e 29 April 2011 9:34
-
29 April 2011 9:37Scot, very nice and easy to catch videos. Exactly what newbie like me needs ) Thank you very much !
-
24 Juli 2012 12:41
Scot hello.
Could u tell me why "Workflow is marked as Complete, No tasks were created." but Ihave done all like u describe ?
-
24 Juli 2012 19:40
Did you get my source code?
Scot
Author, Professional Business Connectivity Services
Author, Inside SharePoint 2010 Blog, www.shillier.com
Twitter, @ScotHillier
SharePoint Trainer, Critical Path Training -
25 Juli 2012 3:47Scot yes I use your sample, but tasks aren't created and workflow Completed...
-
09 Agustus 2012 12:12
Scot hi
Could u tell me how can I complete all tasks if one of them was rejected by user and I need to complete workflow?
Now I'm using :
thistask.Web.AllowUnsafeUpdates = true; ht[SPBuiltInFieldId.Completed] = "TRUE"; ht["Completed"] = "TRUE"; ht[SPBuiltInFieldId.PercentComplete] = 1.0f; ht["PercentComplete"] = 1.0f; ht["Состояние"] = Constants.TaskStatuses.Completed; ht[SPBuiltInFieldId.TaskStatus] = SPResource.GetString(new CultureInfo((int)thistask.Web.Language, false), Strings.WorkflowTaskStatusComplete, new object[0]); ht[SPBuiltInFieldId.WorkflowOutcome] = "Rejected"; ht["TaskStatus"] = "Completed"; ht["FormData"] = SPWorkflowStatus.Completed; ht["WorkflowOutcome"] = "Rejected"; try { SPWorkflowTask.AlterTask((thistask as SPListItem), ht, true); } catch { } thistask.Web.Update();
But my workflow for current item doesn't completed ...
Thanks in advance.
- Diedit oleh Connoisseur 09 Agustus 2012 12:13