Workflow – Basics; Custom Workflow Example

You can create workflows using the following two developer applications:

  • For workflows that include custom code and employ forms, use Visual Studio 2010 Workflow Designer. If you use Visual Studio, you can also use forms technologies, such as Microsoft ASP.NET, to create forms that can interact with and gather information from users. For more information, see Workflow Forms Overview in the Microsoft SharePoint 2010 Software Development Kit (SDK).
  • For declarative, rules-based workflows that contain no code, and that are developed against a specific SharePoint site, use Microsoft SharePoint Designer 2010.

—————————————————————————————————

One can use Infopath 2010 to create forms that can host with (1) MS Office system client application and (2) on the SP 2010 server.

InfoPath 2010 gives you the ability to create symmetrical forms—forms that look and operate exactly the same way whether they are displayed in the SharePoint Server 2010 Web interface, or within a Microsoft Office system client application, such as Word, Excel, or PowerPoint.

—————————————————————————————————-

The following is a custom workflow sample from MSDN:
http://msdn.microsoft.com/en-us/library/ee231573.aspx

  1. First add 3 new columns in the “Shared Documents” document library – (1) Document Status, (2) Assignee and (3) Review Comments. But really you only need the first one as the other two are not used in this example.
  2. The workflow status will be set to “In Progress” or “Completed” based on this column.
  3. When a new document is uploaded/added, the onWorkflowActivated method is invoked, which calls checkStatus(). checkStatus()
    checks the value of Document Status; if it’s Review Completed, then workflowPending is set to true (meaning workflow is Completed). Or else, the workflow is still In Progress.

  4. Same thing happens when a document is updated.

Here are the (1) VS 2010 custom workflow (sequential workflow template) design view, (2) code behnd, and (3) Share Ddocument view:


namespace MySharePointWorkflow.Workflow1

{  

public
sealed
partial
class
Workflow1 : SequentialWorkflowActivity

{

Boolean workflowPending = true;  

private
void checkStatus()

{

if ((string)workflowProperties.Item[“Document Status”] == “Review Completed”)

workflowPending = false;

}  

public Workflow1()

{

InitializeComponent();

}  

public
Guid workflowId = default(System.Guid);

public
SPWorkflowActivationProperties workflowProperties = new
SPWorkflowActivationProperties();

private
void onWorkflowActivated(object sender, ExternalDataEventArgs e)
When workflow activated (new doc)

{

// Check the status.

checkStatus(); Check workflow should be set to ‘completed’
 

}  

private
void isWorkflowPending(object sender, ConditionalEventArgs e)

{

e.Result = workflowPending;
 

}  

private
void onWorkItemChanged(object sender, ExternalDataEventArgs e)
When doc edited (updated doc)

{

// Check the status.

checkStatus(); Check workflow should be set to ‘completed’
 

}

}

}  

Take this home – as this is somewhat confusing —

In a whileActivity1, if the ConditionalEventArgs e’s result (i.e., e.result):

is set to true, then workflow continues (loop back to starting point), and thus workflow still in progress;

is set to false, then workflow is finished/completed.



  

Advertisements
Post a comment or leave a trackback: Trackback URL.

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

%d bloggers like this: