Custom activities for your workflows

17 05 2007

When working with workflows, you will quite soon hit the dead end of the available possibilities and go “Hmmm, how can I make this a little different?”. That’s our spirit. One of the approaches is to create custom activities that you can add to your workflows. This sample creates a custom activity that will appear Custom activities should be developped and installed as features for simplicity of deployment and for keeping your house clean.

So, what do we need?

  1. Get a sample code from here.
  2. Craft it your way and BTW, to debug workflows, attach your debugger to the process w3p.exe that refers workflows.
  3. Sign your dll (need help on this? See How to install an assembly into the Global Assembly Cache in Visual C#)
  4. Deploy your dll to the GAC(ok, ok you didn’t create the feature yet… just copy/paste it or drag & drop your dll to your GAC folder it should be something like c:\windows\assembly)
  5. Edit the web.config of the site where you want this activated
    1. look for the section <authorizedTypes></authorizedTypes>
    2. add the node 

  6. <authorizedType Assembly="<NAME.OF.YOUR.CLASS>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=<PUBLIC_KEY_HERE>" Namespace="<NAME.OF.YOUR.CLASS>" TypeName="*" Authorized="True" />

  7. Edit your WSS.ACTIONS file (look in  C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\Workflow\)
  8. Look for the section <ACTIONS></ACTIONS>
  9. Add a node


<Action Name="<DISPLAY NAME YOU WANT>" ClassName="<CLASS_NAME>" Assembly="<CLASS_NAME>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=<PUBLIC_KEY>" AppliesTo="all" Category="Sample">   <RuleDesigner Sentence="Sting you want to appear on the workflow designer with one parameter %1 and a second parameter %2.">
        <FieldBind Field="ParameterOne" Text="First parameter text" DesignerType="TextArea" Id="1"/>
        <FieldBind Field="ParameterTwo" Text="Second parameter text" DesignerType="TextArea" Id="2"/>
   </RuleDesigner>
   <Parameters>
        <Parameter Name="ParameterOne" Type="System.String, mscorlib" Direction="In" />
        <Parameter Name="ParameterTwo" Type="System.String, mscorlib" Direction="In" />
  </Parameters>
</Action>

Now you should be able to see your activity when you are deigning a workflow in Sharepoint Designer, go to File > New > select the Sharepoint Tab > select Blank workflow. The designer is started up and when you reach the actual workflow design page (second page), you will have your activity on the Actions list, as shown bellow. Just add your activity, configure the parameters and that’s it!
Workflow designer

Here are some useful links:

Advertisements

Actions

Information

2 responses

5 07 2007
Robin

Mate, thanks for mentioning my blog in the first step! 🙂

11 07 2007
ruimelo

Hey Robin. Your quite wellcome. Good posts should be pointed out 😉

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: