I have learned about Workflow by dropping and clicking and the next phase is learn how to create WF with C# based this link (http://channel9.msdn.com/Series/Reimagine-SharePoint-Development/Translating-Custom-Code-Workflows-to-SharePoint-2013)

What material, link etc can you recommend me to learn about creating WF with C# coding? I have previous knowledge in ASP.net, regular c# coding etc but not in relation to WF with C# code.

  • i am also desperately looking for creating custom state machine workflows with visual studio 2013 on sharepoint 2013 . thats associated to a splist or spdocument library.if its asscoiated with a custom content type that has aspx as association form.
    – samolpp2
    Commented Mar 13, 2017 at 6:50

2 Answers 2


There are basically two types of workflows we can create in Visual Studio:

  1. Sequential Workflow.
  2. State Machine Workflow.

Following articles gives you basic idea behind both WF:

Article-1 : Difference Between Sequential Workflow & State machine workflow?
Article-2 :MSDN Blog

Following articles helps you to create sequential workflows in visual studio:

  1. https://sergeluca.wordpress.com/2011/01/06/step-by-step-tutorial-creating-workflows-for-sharepoint-2010-step-115/

  2. https://babu143.wordpress.com/2012/12/24/creating-a-sequential-workflow-for-sharepoint-2010-using-visual-studio-a-step-by-step-guide/

  3. https://msdn.microsoft.com/en-us/library/office/hh824675%28v=office.14%29.aspx

  4. http://www.nothingbutsharepoint.com/2012/12/20/sequential-workflow-in-sharepoint-2010-using-visual-studio-2010-aspx-2/

  5. http://www.c-sharpcorner.com/blogs/how-to-create-sequential-workflow-in-sharepoint-2010-using-visual-studio-2010

  • have you worked on this previosuly with SP 2013 as platform for creating sequential / state machine, please lets us know and what steps need to be created for creating the same in SP 2013 platform and how to take actions like approve /reject/send back to requestor state using the pure C#.
    – samolpp2
    Commented Mar 13, 2017 at 6:52

Here is the good example to start with SP workflow using Visual studio.

Please follow the below steps:

1-Start with a Sequential Workflow. Start Visual Studio and create a new project from the template SharePoint --> Sequential Workflow.

2-In the next screen select the option Site Workflow.

3-In the next screen, leave the default option saying the user manually starts the Workflow.

4-Create Activity

What is an Activity?

A Workflow consists of a series of Activities. We can add Activities using the Toolbox. There are different types of Activities like Code Activity, SendEmail, etc.

5-Drag and drop a Code Activity from the toolbox.

6-Add code for the Activity, add code for this Activity. Double click on the codeActivity1

    private void codeActivity1_ExecuteCode(object sender, EventArgs e)
    using (SPWeb web = SPContext.Current.Web)
    SPList list = web.Lists["Manager"];
    foreach (SPListItem item in list.Items)
        if (item["Address"] == null)
            item["Address"] = "PLEASE SET THE ADDRESS!";


7-Build and Deploy the Solution.

  • 1
    You don't need to manually dispose SPWeb from SPContext.Current.Web
    – dbardakov
    Commented Dec 27, 2015 at 3:18
  • But , this will have problems when creating custom content types with aspx forms. how to create a custom approval form using the aspx pages / site pages? how to achieve these things? here is MVP Serge's blog about it :sergeluca.wordpress.com/2013/04/08/… also another thread discusses about this : sharepoint.stackexchange.com/questions/184624/…
    – samolpp2
    Commented Mar 13, 2017 at 6:43
  • From MSDN: “Unlike previous versions, SharePoint 2013 does not support workflows that are scoped to a content type (SPContentType). However, the messaging infrastructure is extensible, so it can support any arbitrary scope. As a developer, you can set the EventSourceId property on a given WorkflowSubscription instance to any guid. You can then use that EventSourceId value to call PublishEvent(Guid, String, IDictionary<String, Object>), which triggers a new workflow instance of the specified WorkflowSubscription.”. I haven't found a workaround either. Case closed.
    – samolpp2
    Commented Mar 13, 2017 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.