Hey guys,
Today i want to show you how to create a new Custom Activity for SharePoint.
System
Requirements:
-
VS
2005/2008
-
Windows
Workflow Extensions for VS
-
WSS
3.0 SDK for VS
-
SharePoint
2007 Server or WSS 3.0
How to start:
First of all open
your Visual Studio and navigate to File-> New-> Project -> Workflow
Activity Library
A new Project
with one Activity will be loaded. Now we can begin to develop our Custom
Activity for SPD (SharePoint Designer).
At first we have
to specify the Dependency Properties, these are the Properties which interacts
with SPD Workflow Wizard. The Declaration is as following:
private static DependencyProperty
MessageProperty = DependencyProperty.Register("Message", typeof(string), typeof(YourCustomActivity));
The next step is to define
the properties for internal use. There are several Options which can be given
to the property.
[Description("Message ")]
[ValidationOption(ValidationOption.Required)]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string ToList
{
get
{
return ((string)(base.GetValue(YourCustomActivity.MessageProperty)));
}
set
{
base.SetValue(YourCustomActivity.
MessageProperty, value);
}
}
So now we are ready for implementing our
CustomActivity. So you have just to override the Execute method. Here is a
little example which only writes an eventLog entry to the application log.
protected override ActivityExecutionStatus
Execute(ActivityExecutionContext
executionContext)
{
try
{
EventLog.WriteEntry("Workflow Test", this.Message, EventLogEntryType.Information,
9999, 4);
return
ActivityExecutionStatus.Closed;
}
catch (Exception ex)
{
return ActivityExecutionStatus.Faulting;
}
}
The last step which we have
to do with coding is to rename the SequenceActivity to Activity.
public partial class YourCustomActivity: Activity
Now we have to sign
the assembly with a strong name and build the solution. I will describe the Deployment procedure for a custom Activity in another post.
Posted
Jul 22 2008, 05:31 PM
by
Nadine Storandt