none
Replicator in Sharepoint workflow don't instanciate all tasks

    Question

  • Hi all,

    I will apreciate your help in a sharepoint workflow related issue.

    In a workflow that assignes tasks to a list of users, i have a custom activity that assignes taks to users based on a list given in a replicatar initialChildData.

    a replicator is running on parallel mode.

    All is going well, the only problem i have is that i have always a single non assigned task, if i have 10 tasks, only 9 are correctely assigned the left one have it's AssignedTo and title to null;

    Im debugging for 2 days now and can't find any solution.

    help plz.

    It seems that the replicator passes the correct parameters to my activity, the problem is that when assigning task, the first AssignedTo is empty, so the last AssignedTo member from my list is left whith no task


    • Modifié Brahim belf vendredi 22 juin 2012 15:45 addition
    vendredi 22 juin 2012 15:33

Réponses

  • Solved.

    It seems i must initialize first task in the replicator initiamized this way :

            private void replicateTasks_Initialized(object sender, EventArgs e)
            {
                //replicateTasks.InitialChildData = users;
                readActivity.TaskTitle = "task for : " + users[users.Count - 1].ToString();
                readActivity.TaskAssignedTo = users[users.Count - 1].ToString();
            }

    • Marqué comme réponse Brahim belf lundi 25 juin 2012 09:24
    lundi 25 juin 2012 09:24

Toutes les réponses

  • Here is a screen of the task created with AssignedTo field empty.


    The code of my workflow looks like this :

            private void replicateTasks_ChildInitialized(object sender, ReplicatorChildEventArgs e)
            {
                readActivity.TaskTitle = "task for : " + e.InstanceData.ToString();
                readActivity.TaskAssignedTo = e.InstanceData.ToString();
            }
            private void onWorkflowActivated_Invoked(object sender, ExternalDataEventArgs e)
            {
                users = getUsersToNotify();
                workflowId = Guid.NewGuid();
            }

    the code in my custom activity :

      public partial class ReadActivity : SequenceActivity
        {
            public ReadActivity()
            {
                InitializeComponent();
            }
            public Guid readTask_TaskId = default(System.Guid);
            public Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties readTask_TaskProps = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
            bool isTaskFinished = false;
            public string TaskTitle { get; set; }
            public string TaskAssignedTo { get; set; }
            public Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties onReadTaskChanged_AfterProps = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
            public Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties onReadTaskChanged_BeforeProps = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();
            public String ReadTaskOutcome = default(System.String);
            private void checkTaskFinished(object sender, ConditionalEventArgs e)
            {
                e.Result = !isTaskFinished;
            }
            private void readTask_MethodInvoking(object sender, EventArgs e)
            {
                readTask.TaskId = Guid.NewGuid();
                readTask_TaskProps.Title = TaskTitle;
                readTask_TaskProps.AssignedTo = TaskAssignedTo;
                isTaskFinished = false;
            }
            private void onReadTaskChanged_Invoked(object sender, ExternalDataEventArgs e)
            {
                isTaskFinished = onReadTaskChanged_AfterProps.PercentComplete == 1.0;
            }
            private void completeReadTask_MethodInvoking(object sender, EventArgs e)
            {
                ReadTaskOutcome = string.Format("Task finished by  {0}, on {1} " , readTask_TaskProps.AssignedTo.ToString(), DateTime.Now);
            }

    Help plz
    lundi 25 juin 2012 08:42
  • Solved.

    It seems i must initialize first task in the replicator initiamized this way :

            private void replicateTasks_Initialized(object sender, EventArgs e)
            {
                //replicateTasks.InitialChildData = users;
                readActivity.TaskTitle = "task for : " + users[users.Count - 1].ToString();
                readActivity.TaskAssignedTo = users[users.Count - 1].ToString();
            }

    • Marqué comme réponse Brahim belf lundi 25 juin 2012 09:24
    lundi 25 juin 2012 09:24