Difference between workflow created using SharePoint Designer and Visual Studio Designer for Windows Workflow Foundation.

SharePoint Designer

Visual Studio 2005 Designer for Windows Workflow Foundation.

 

Can write only sequential workflows.

Can write both sequential and state machine workflows.

 

Automatic deployment against the specific list or library against which workflow is being designed.

Can be deployed as a feature.

Logic is defined declaratively using Steps which comprises of Conditions and Actions

Logic could be defined through custom code written using C# or VB.NET.

Workflows could be associated to a specific list or library.

Workflow can be authored as Template which once deployed could be associated with any list or library.

Workflow modifications not possible.

Workflow modifications are possible using Modification forms built using ASP.NET or InfoPath form.

Workflow markup, rules all are stored as a document library on the site.

Workflows are compiled as an .NET assembly.

Can’t be debugged.

Debugging is possible using Visual Studio.

Advertisements

Using Workflow Object Model in SharePoint.

I was assigned a task to create a simple aspx page where the user could see all the all the different documents, workflows running against them, workflows task information as well as workflow history.

Here we can make use of SPWorkflow and SPWorkflowTask class.

The page would be displaying the information in the following manner

Workflow status for following document :-SampleDocument1
Workflow name :- Approval Workflow
Workflow Task Title
First Team Task
Second Team Task
Third Team Task
Workflow History Description
The approval workflow has started waiting for and Second Team to respond
Task has been created and assigned to First and Second Team
First and Second team has completed their task

Workflow status for following document :- SampleDocument2
Workflow name :- Approval Workflow
Workflow Task Title
First Team Task
Workflow History Description
The approval workflow has started waiting for First and Second Team to respond

The sample code for getting the above information

protected void Page_Load(object sender, EventArgs e)

{

//SPWorkflowManager myWFMgr = new SPWorkflowManager();

SPSite objSite = new SPSite(http://servername:port”);

SPWeb objWeb = objSite.OpenWeb();

SPList myList = objWeb.Lists[“ListName”];

// for each document within the Library

foreach (SPListItem myListItem in myList.Items)

{

Response.Write(“<b>Workflow status for following document :-</b>” + myListItem[“Title”].ToString());

Response.Write(“</br>”);

// Get the workflows associated

foreach (SPWorkflow myWF in myListItem.Workflows)

{

// Get the name of the workflow

Response.Write(“Workflow name :- “+ myWF.ParentAssociation.Name);

Response.Write(“</br>”);

Response.Write(“<b>Workflow Task Title </b>”);

Response.Write(“</br>”);

// for each workflow running get the workflow tasks and history information

foreach (SPWorkflowTask myWFTask in myWF.Tasks)

{

Response.Write(myWFTask[“Title”].ToString());

Response.Write(“</br>”);

}

// for each workflow running get the history information

Response.Write(“<b>Workflow History Description</b> “);

Response.Write(“</br>”);

SPList myList1 = objWeb.Lists[“Workflow History”];

SPQuery query = new SPQuery();

query.Query = “<OrderBy><FieldRef Name=”ID”/></OrderBy>” +

“<Where><Eq><FieldRef Name=”WorkflowInstance”/>” +

“<Value Type=”Text”>{“ + myWF.InstanceId.ToString() + “}</Value>” +

“</Eq></Where>”;

SPListItemCollection historyListItems = myList1.GetItems(query);

foreach (SPListItem i in historyListItems)

{

Response.Write( i[“Description”].ToString());

Response.Write(“</br>”);

}

}

Response.Write(“</br>”);

}

}

That’s it …