none
Problem creating multipe tasks - Correlation value on declaration "taskToken" is already initialized. RRS feed

  • Question

  • Hi,
    I have a  simple statemachine workflow which needs to create a task
    everytime it hits a specific state. So for example

    State 1:  Creates the task and moved to "State 2".
    State 2:  Waits for an onTaskChanged and then moves back to "State 1" (
    which would then create a new task and move to "State 2" etc.)

    The workflow works fine the first time round. It creates a task and moves to
    "State 2" however when I trigger the onTaskChange event and it moves back to
    "State 1" to create another task I get the error:
    "Correlation value on declaration "taskToken" is already initialized." in
    the log file (where "taskToken" is the name of my correlation token for the
    CreateTask" activity).

    The correlation token for My CreateTask activity is called "taskToken" and
    is different than the workflow correlation token. My TaskID property is
    bound to a public Guid variable called taskID which is set to a new guid on
    the method invoked by the create task activity, and my TaskProperties are
    bound to a public variable "taskProperties" see the extract below:

           

    Code Snippet
    public Guid taskID = default(System.Guid);
    public SPWorkflowTaskProperties taskProperties = new Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties();

            private void createTask1_MethodInvoking(object sender, EventArgs e)
            {
                taskID = Guid.NewGuid();
                taskProperties.AssignedTo = @"test\john.smith";
                taskProperties.DueDate = DateTime.Now;
                taskProperties.Title = "Approval request for document: " +
    DateTime.Now.Millisecond.ToString();
                taskProperties.Description = "TEST!!!!!!!!!!!!!!!";

            }

     

     

    Any help would be appreciated,

    Thanks,

    Nick

    Wednesday, February 13, 2008 1:09 PM

Answers

  • I think you will be better off using a Replicator Activity to create multiple tasks.  Since the CreateTask activity has already fired, the correlation token is un-usable afterwards.  When you use the Replicator Activity, then the replicator "Clones" the CreateTask and the correlation token.

     

    There are several examples of using the Replicator in the ECM.  Just in case you don't have the ECM, you can download it with the OfficeServerSDK.exe on Microsoft's site.

     

    Good Luck

     

    Bryant

     

    Wednesday, February 13, 2008 3:42 PM

All replies

  • I think you will be better off using a Replicator Activity to create multiple tasks.  Since the CreateTask activity has already fired, the correlation token is un-usable afterwards.  When you use the Replicator Activity, then the replicator "Clones" the CreateTask and the correlation token.

     

    There are several examples of using the Replicator in the ECM.  Just in case you don't have the ECM, you can download it with the OfficeServerSDK.exe on Microsoft's site.

     

    Good Luck

     

    Bryant

     

    Wednesday, February 13, 2008 3:42 PM
  • Hi Byrant,

    Thanks for responding,

    Unfortunately the Replicator Activity doesn't fit the scenario I gave (I need to use a state machine workflow pretty much as outlined above ).

    Does this mean that as far as you are aware you can't dynamically create multiple tasks in a state machine workflow? if this is the case it's a pretty big drawback with state machine workflows.

     

    Nick

    Wednesday, February 13, 2008 5:34 PM
  •  

    I cannot say for absolute certainty, but I think you have to use the Replicator to dynamically create tasks from the same stage.  I don't know your scenario, but could you use multiple stages?

     

    By the way, why can't you use the Replicator?

     

    Bryant

    Wednesday, February 13, 2008 8:04 PM
  •  

    This Correlation token problem arises due to the "OwnerActivityName" sub-property of Correlation token.This property defines

    the scope of activity...which here we set to "Workflow".

    because of which we can not create new instance of task in same  workflow instance..

    If you set this property of the task activity to it's container state it will automatically generate new token to task when

    new instance of the state gets created.but in this case as you have limited the scope of it to it's container state ,that

    task will not be accessible in other states..

    one solution to it is instead of using two states one to create task and one to complete it ,handle all the activities of
    that task in one state only and again go to same state..

    Add state initialization and event driven activity to state activity
    Create the task in state initialization activity
    Add  the taskchanged activity in eventdriven activity in same state and then add complete and delete task activity. After

    that set transition state to same state  if we want to create the task again or  to other state
    It works fine..

     

    • Proposed as answer by vt_asparagus Thursday, September 11, 2008 1:00 AM
    Monday, March 24, 2008 8:50 AM
  • This is the correct solution Suchita!!! Thanks a lot, now I am your big fan, jajajaja
    Carlos A. Martinez
    • Proposed as answer by vt_asparagus Thursday, September 11, 2008 1:00 AM
    Tuesday, July 29, 2008 9:31 PM
  • Hi Carlos:

      Please help me regarding this. I want same scenareo. Actually i could not get the activities like: state initialization activity and state activity.

     

    Thank u


    Goud
    Wednesday, February 4, 2009 12:34 PM
  • This post is too old, but I hope my tip will be useful for you that is looking for it now!

    This problem occur when you create a new state and define a new correlation token owned by "Workflow1" by default.

    You need to create a state and keep all related activities in this state. Then you need create a new correlation token and assigning it to current state, and no more errors.

     

    Follow the steps!

    1) Create a new state named StateA for example.

    2) Add a StateInitialization. Inside it put the CreateTask action and define the correlationToken named myToken and assign it to StateA in OwnerActivityName field.

    3) Add an EventDriven. Inside it put the onTaskCreated if you need it and set the correlationToken as myToken.

    4) Add a new EventDriven. Inside it put a onTaskChanged and set up the correlationToken like previous step.

    In the same EventDriven Acitivity add a CompleteTask to finalize the activity. Set up the correlationToken like previous step too.

     

    An useful page about Workflows issues and resolutions: http://www.sharepointnutsandbolts.com/2008/02/more-workflow-issues-and-resolutions.html 

     

    []s and go ahead!

    Always studing and learning!!!!

    Michel Marcondes

     

     

    • Proposed as answer by SPAnton2010 Monday, October 24, 2011 1:53 PM
    • Unproposed as answer by SPAnton2010 Monday, October 24, 2011 2:07 PM
    Saturday, June 12, 2010 10:46 PM
  • This article hels you.

    Microsoft Student Partner, MCTS. Мой блог.

    Saturday, March 10, 2012 10:36 PM