Uncategorized

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.

Creating a Sequential workflow project

Creating a Sequential workflow project

(2) Deployed it as a Farm Solution because it is a site workflow.

Deployed as Farm Solution bcs its SiteWorkFlow which do not need any list to associate

(3) Choose a site workflow.

Choose it as site workflow bcs it no need to have any list

Choose it as site workflow bcs it no need to have any list

 

 
(4) Check History list to capture the history log of the workflow, And Task to Create Task in our workflow. Click Finish.

Setting WorkFlowHisotyList for History of WorkFlow

Setting WorkFlowHisotyList for History of WorkFlow

(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.

Simple Workflow Project Created, Drag Create Task method form ToolBox

Simple Workflow Project Created, Drag Create Task method form ToolBox

define the properties of the Task in the vs2010

define the properties of the Task in the vs2010

(7) Now Create new Task Properties.

Creating Task properties of mytask

Creating Task properties of mytask

(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.

methodEnvoking of MyTask event

methodEnvoking of MyTask event

setting the description and the title of our new Task

setting the description and the title of our new Task

co-relate the Workflow Task with onTaskChange Event
co-relate the Workflow Task with onTaskChange Event

(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.

Define the Same Tasktoen with TaskChange event

Define the Same Tasktoen with TaskChange event

(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.

using execute code to update list

using execute code to update list

updating list very sime :)

updating list very sime🙂

(11) Choose site workflow

going to site workflow

going to site workflow

out co-relation workflow

(12) Waiting for task to change, workflow status is Inprogress.

inprogress and wating for task to change

inprogress and wating for task to change

log history and of task in workflow

log history and of task in workflow

(13) Change the Content of Task to Change so that it will resume the workflow.

changing content of task to co-relation works

changing content of task to co-relation works

workflow complete when task change

workflow complete when task change

Standard

One thought on “Correlation Tokens in SharePoint 2010 Workflow [WorkFlows in Visual Studio 2010]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s