Problem By Correlation Token:-
(4) Check History list to capture the history log of the workflow, And Task to Create Task in our workflow. Click Finish.
In approval workflow it is quite common to give the approver possibility to ask for additional information. When I develop sequential workflow I am modeling it the way this picture shows.
In other words first task "managementApproveTask" is creted and when the manager ask for additional information then "addManagementInfoTask" is created. Whene the person adds the information the big WHILE returns and creates new task for the manager to approve the document - this gives the manager the possibility to ask for additional information as many times as he wants and ask different people and so on...
Well then the question is which activity set as the owner of CorrelationToken of the CreateTask activity and also of OnTaskChanged activity - because they are always the same.
If you set the "ManagementApproveActivity" or any other activity PARENT TO THE WHILE loop as the owner of the CorrelationToken, you will get the following error:
System.InvalidOperationException: Correlation value on declaration "TOKEN NAME" is already initialized.
at System.Workflow.Runtime.CorrelationToken.Initialize(Activity activity, ICollection`1 propertyValues)
at System.Workflow.Activities.CorrelationService.InvalidateCorrelationToken(Activity activity, Type interfaceType, String methodName, Object[] messageArgs)...
The problem is as the exception says that the Correlation Token is already initialized. To resolve this you have to set as Owner activity of the CorrelationToken any activity inside the WHILE loop. Then any time the while loop is entered the activities inside are recreated, that means that there will be also new CorrelationToken created for each new task.
In other words first task "managementApproveTask" is creted and when the manager ask for additional information then "addManagementInfoTask" is created. Whene the person adds the information the big WHILE returns and creates new task for the manager to approve the document - this gives the manager the possibility to ask for additional information as many times as he wants and ask different people and so on...
Well then the question is which activity set as the owner of CorrelationToken of the CreateTask activity and also of OnTaskChanged activity - because they are always the same.
If you set the "ManagementApproveActivity" or any other activity PARENT TO THE WHILE loop as the owner of the CorrelationToken, you will get the following error:
System.InvalidOperationException: Correlation value on declaration "TOKEN NAME" is already initialized.
at System.Workflow.Runtime.CorrelationToken.Initialize(Activity activity, ICollection`1 propertyValues)
at System.Workflow.Activities.CorrelationService.InvalidateCorrelationToken(Activity activity, Type interfaceType, String methodName, Object[] messageArgs)...
The problem is as the exception says that the Correlation Token is already initialized. To resolve this you have to set as Owner activity of the CorrelationToken any activity inside the WHILE loop. Then any time the while loop is entered the activities inside are recreated, that means that there will be also new CorrelationToken created for each new task.
Workflow – What is a Correlation Token?
Correlation tokenas a unique identifier that enables mapping between the objects in a workflow and the environment that is hosting the Windows Workflow Foundation (WF) workflow runtime.
You will have a separate correlation token for the each of the following:
You will have a separate correlation token for the each of the following:
- The workflow itself
- Each task you need to reference in the workflow
Correlation Tokens in SharePoint 2010 Workflow [WorkFlows in Visual Studio 2010]
One of the greate feature I found in the SharePoint is the Powerfull engine for developing the Workflows by visual studio 2010. some of the greate feature I love to capture in my blog, which help me out in future to remember whenever I need any one of them. The most immense topic is corelation properties.
I used Co-releatoin property in the BizTalk Server 2006, Still I quite impress with this Microsoft methodology to integrate different line of business. In sp 2010 again I am using the co-relation property in one of my workflow.
You can consider a correlation token as a unique identifier that enables mapping between the objects in a workflow and the environment that is hosting the Windows Workflow Foundation (WF) workflow runtime.
Useful Link : http://msdn.microsoft.com/en-us/library/ms475438.aspx
Whenver you create a sequential workflow project in Visual Studio 2010 for SharePoint , it will prompt to ask name several times, which may confusion with which will be the workflow name.
There are actually three names that are used when creating workflows in Visual Studio 2010.
The first is the name of the project item,
second the name of the workflow itself—as defined in the Elements.xml file under the workflow project item folder
third is the name of the association.
(1) Create a new Project in Vs2010, Select SharePoint Template form left pane and Choose Sequential WorkFlow item from right pane.
(2) Deployed it as a Farm Solution because it is a site workflow.
(3) Choose a site workflow.
(4) Check History list to capture the history log of the workflow, And Task to Create Task in our workflow. Click Finish.
(5) Simple WorkFlow project has been created. Our First event on this WorkFlow is OnWorkFlowInitiated event.
Create a TaskToken as MyToken and Define the Task Id by Click on the Properties and also create an new GUID for our Task.
Create a TaskToken as MyToken and Define the Task Id by Click on the Properties and also create an new GUID for our Task.
(7) Now Create new Task Properties.
(8) Generating Method Invoking Event to provide description and title for the task. We can also provide more detail regarding the Task but now we just put title and description, and mentioned new Guid for this Task.
(9) Drag a OnTeskChange event, and put name as WhenMyTaskChange.On the Properties set the Corelation Token as of TaskToken, so that both will be use a same uniuque corelation Id and set as MyTask_Id.
(10) Drag the Code Executer (Code Activity) on the design , and set the methodinvoking on which we are updating a content of our list. we can do anything with list, add update delete list , content type etc. Previously in BiZtalk server 2006 it CodeActivity was not there for this we used to add the classlibrary for data manipulation.
(11) Choose site workflow
(12) Waiting for task to change, workflow status is Inprogress.
(13) Change the Content of Task to Change so that it will resume the workflow.
No comments:
Post a Comment