HOW TO: Develop a workflow code activity in SharePoint 2013

This post is a contribution from Raghavendra B Nanjaiah, an engineer with the SharePoint Developer Support team.

First part is to create our code activity and let the Workflow Manager and SharePoint 2013 know about it.

1. In VS 2012, click New Project, Workflow and choose Activity Library.


2. Delete the declarative Activity1.xaml from the solution since we will be creating our own custom code activity.

3. In solution explorer on newly created activity library right click and select add new item -> Workflow -> Code Activity.


4. Decide what data you would like to pass in to custom activity. In my case I am accepting string as InArgument and trying to create new list item based on the input string parameter  (you can also use OutArgument which represents the flow of data out of an activity).


5. Write your activity logic in overridden execute method.

6. Build the Project and sign the code activity assembly.

7. Now, Create a new xml file and name it as AllowedTypes.xml and add the reference of you activity library dll , Namespace and type as shown below ( this basically adds your assembly to whitelist which Workflow service trust and loads. If your assembly is not in whitelist you might receive activity not found exception)


8. Now it's time to deploy our assembly and allowedtypes.xml to the folder from where Workflow manager and SharePoint can read.

* On the Workflow Manager box you have to:

     - Copy activity assembly to following locations:

          > %ProgramFiles%\Workflow Manager\1.0\Workflow\Artifacts

          > %ProgramFiles%\Workflow Manager\1.0\Workflow\WFWebRoot\bin

     - Add your activity class to the white-list

          > Copy AllowedTypes.xml  also to above two locations

     - Restart “Workflow Manager backend” service

* On SharePoint box you have to:

     - Copy activity assembly to SharePoint box and install it in the GAC.

     - Reset IIS


Now, the second part is to create a workflow using custom code activity that we created by following the above steps.

1. Now in the same visual studio solution where you have custom code activity add new SharePoint 2013 Workflow project.

2. From the toolbox drag and drop the custom code activity that we just developed.


3. Right click and deploy the solution to your SharePoint site.


Bingo! Now we have developed and deployed custom code activity Workflow in SharePoint 2013 with Workflow Manager 1.0. Smile

Hope this helps!

Comments (31)
  1. Anonymous says:

    I can not find the Sharepoint 2013 Workflow Project Template in either VS 2010 or in VS 2013, can you provide a little more guidance on this?


  2. Anonymous says:

    @dlr442218: Download and install SharePoint 2013 development tools from here:…/fp123627.aspx.  Click "Download the tools" in the section "Microsoft Office Developer Tools for Visual Studio 2012".

  3. Ed (DareDevil57) says:


  4. very good i use your post to create my our Custom Activities

  5. Anonymous says:

    Please try VS2012!

  6. Anonymous says:

    Very useful post!!! Thanks a lot.

    Can you describe me how can i use may code activity in other sharepoint project. Its not visible in Tools window any if i add my custom activity dll from GAC.

    Many Thanks.

  7. Use webservice says:

    I think it is a better idea to implement custom code as webservice instead of a custom activity. This method is fully supported in deployment and execution.

  8. Eric says:

    When you establish a new ClientContext, does this run with workflow app-permissions, or as the Workflow Service Account

    I have found that i have to give the Workflow service account explicit permissions on the resources needed, to avoid a 401 error when creating a new clientcontext


    BigProfitbuzz is an Indian stock market advisory firm. BigProfitbuzz proven month after month that trading and investing in stock market can be profitable whether market is bull or bear. As suggested last week our all client made a very good profit in the buy position of NIFTY. Now for the coming week we suggest all the traders to make a sell position in NIFTY around 6200-6250 with stoploss 6400 for the target of 5900-5800.This is due to that NIFTY is unable to sustain its peak so traders can make a sell position to make some profit. You can also can make sell position in NIFTY stocks also. But keep the strict stoploss of 6400 for the NIFTY & NIFTY stocks. For further update visit our website.



  10. Nehal Bhandari says:

    The steps for writing .actions4 file are missing.

  11. Beware says:

    Beware that this will not work in SharePoint Online

  12. Beware says:

    Beware that this will not work in SharePoint Online

  13. mike says:

    This is a problematic solution. Manually copying files to a workflow server is problematic, as a new server could be added to the farm at any point, at which point the workflow is broken until the dlls are copied over.

  14. la_bruin says:

    Horrible approach with the need for manual copying dlls etc.
    Thanks for throwing us 10 years back in time Microsoft!
    I’ll stick to a web service approach, which is not ideal, but at least not as horrible as the approach described on this page.

  15. Ghost says:

    Thanks, very helpful. Just one question, I modified my code activity and rebuild it, but now i have three locations where my dll was deployed. What’s the correct deploy step?

  16. Soumyadev says:

    If the custom code activity has some functionality written which will use object model of sharepoint, then will all WFM servers need to have WFE role?

  17. Arcandotnet says:

    This cannot be the only way to run C# from a workflow in SharePoint 2013??? If it is I will be sticking with Sequential workflows and dealing with the obsolete warnings.

  18. dbh says:

    I get the following error after following your example.

    Error occurred in deployment step ‘Activate Features’: Microsoft.Workflow.Client.ActivityValidationException: Workflow XAML failed validation due to the following errors:
    Invalid type(s) ‘ActivityLibrary1.ActivityLibrary1.CodeActivity1’.
    HTTP headers received from the server – ActivityId: 245e1654-c371-4894-877d-bdfc8e199bae. NodeId: EPMDEVWFM1. Scope: /QA/default/55970cea-4d71-4a9d-8273-b144c64b08cb/6f465a87-16c3-4312-8283-8f6594c399f2. Client ActivityId : 263a39fc-8d9f-42dd-99a6-de7631748b80.
    —> System.Net.WebException: The remote server returned an error: (400) Bad Request.
    at Microsoft.Workflow.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
    at Microsoft.Workflow.Client.HttpGetResponseAsyncResult`1.End(IAsyncResult result)
    at Microsoft.Workflow.Client.ClientHelpers.SendRequest[T](HttpWebRequest request, T content)

    I have placed the AllowedTypes in the locations specified on our Workflow manager server and have copied the dlls to the GAC on both the SharePoint server and the Web Front End server. Additionally, I have disabled the protection form executing code on the
    workflow manager using Set-WFServiceConfiguration -ServiceUri http://epmdevwfm1:12291 -Name WorkflowServiceAllowUnsafeTypes -Value true

    Do I need to do something specifically for the named workflow scope /QA/default ?

    Many Thanks, Des

    1. a bala hari says:

      did you resolve the issue ,I have the same issue ,but not yet resolved, if you have resolved then please share the solution.

  19. SharePoint 2013 Development training Online says:

    Information was good, I like your post.
    Looking forward for more on this topic.">SharePoint 2013 Development training Online

  20. RicardoAleG says:

    Hi Des,

    I don’t know if it is too late, but I was having the same issue even with the latest SharePoint Server 2013 upgrade.

    What I did is to compare the "workflow.xaml" file from a SharePoint Designer workflow (after having saved it as a template into the Site Assets library) with the "workflow.xaml" generated from within Visual Studio 2013. What I found and what resolved my issue
    is to add these two attributes as a part of the Activity element.





  21. SP Designer says:

    Instead of moving on to step two where you create a workflow in Visual Studio, can you instead use these actions from within Sharepoint Designer to make workflows?

  22. @RicardoAleG says:

    How do I save a workflow as a template and get a .xaml file? By default when saving as a template the workflow is saved as a .wsp file, which I can’t really examine to add the tags you mentioned.

  23. Devy says:

    What an amazing number of totally automatable steps to create a code activity that you can use! Way to over complicate things MS – "programming" in .NET is more menu surfing and config file fiddling than coding.

  24. MI says:

    Please what do you means with "Copy activity assembly to SharePoint box" ??

  25. MI says:

    Please what do you means with "Copy activity assembly to SharePoint box" ??

  26. showbox dl says:

    Thanks for the great info. I really loved this. I would like to apprentice at the same time as you amend your web site, how could i subscribe for a blog site?
    For more info on showbox please refer below sites:
    Latest version of Showbox App download for all android smart phones and tablets. – It’s just 2 MB file you can easily get it on your android device without much trouble. Showbox app was well designed application for android to watch movies and TV shows, Cartoons and many more such things on your smartphone.
    For showbox on iOS (iPhone/iPad), please read below articles:
    Showbox for PC articles:
    There are countless for PC clients as it is essentially easy to understand, simple to introduce, gives continuous administration, effectively reasonable. it is accessible at completely free of expense i.e., there will be no establishment charges and after establishment
    it doesn’t charge cash for watching films and recordings. Not simply watching, it likewise offers alternative to download recordings and motion pictures. The accompanying are the strides that are to be taken after to introduce Showbox application on Android.
    The above all else thing to be done is, go to the Security Settings on your Android telephone, Scroll down and tap on ‘Obscure sources’.

  27. a bala hari says:

    Hi I am getting .
    Microsoft.Workflow.Client.ActivityValidationException: Workflow XAML failed validation due to the following errors: Invalid type(s) ‘
    Error while I am activating the feature .can you please help me out

  28. Help says:

    I am getting below error while adding the code activity to sharepoint online site.
    Cannot create unknown type ‘{clr-namespace:ReviewWorkflow}CodeActivity1’.
    Please help on this..

  29. Anonymous says:
    (The content was deleted per user request)

Comments are closed.

Skip to main content