Sharepoint 2013 Workflow Custom Declarative Activity

In SharePoint 2013 it is possible to create custom declarative activities (in Visual Studio 2012), that will be exposed and can be used in SharePoint Designer Workflows. In this way we can extend SPD OOB Workflow Activities.

To create a custom activity, create an Empty SharePoint 2013 project and select the deployment as sandbox solution.

Add a new Item, select Workflow Custom Activity:

WFCA1

Then you will need to create your Workflow Activity actions, use the ToolBox and drag the actions you need.

In my case, I used the “LookupSPPricipal”, that receives a UserLoginName, and will get that user’s information from Sharepoint. The UserLoginName is defined as an input argument to my WF Activity. The output of this action will go to a local variable named “User”.

WFCA2

I used another action “GetDynamicValueProperties” to get the User’s Display Name. This action receives the object “User” and the output goes to  an output argument “DisplayName”

WFCA4

We need to configure the output and input parameters in the file “.actions4”.

wfca8

After that, I deployed my WF and opened SharepointDesigner. I could see my new Activity:

WFCA5

I created a test Site Workflow that calls my Custom Activity, and logs to history list the output “Display Name”:

WFCA6

I published my WF and run it:

WFCA7

Advertisements

Tags: , ,

13 responses to “Sharepoint 2013 Workflow Custom Declarative Activity”

  1. Russell Munro says :

    Great post, one of very few on the subject. My custom workflow action shows up in the list of actions in SP designer but I can make an instance of it appear in workflow GUI. do you know how to fix this?

  2. Антон Сидоров says :

    I am try use you tutorial on SP2013 Foundation, but on activate feature server return error:
    Error occurred in deployment step ‘Activate Features’: Failed to load receiver assembly “Microsoft.SharePoint.WorkflowServices, Version=14.0.0.0,
    Any suggestions?

  3. ezybzy says :

    Thanks for your post. You save my day for .actions4.

    BTW, can you debug it? I’ve separated Workflow Manager from the development machine (SPS + VS on the same machine). I stuck on Web page loading which takes forever.

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: