8 out of 11 rated this helpful - Rate this topic

Develop SharePoint 2013 workflows using Visual Studio

SharePoint 2013

Published: July 16, 2012

Conceptual overview topic

SharePoint 2013 supports two primary workflow development environments for authoring workflows: SharePoint Designer and Visual Studio. This article summarizes both and discusses the advantages and disadvantages of each.

Note Note

For guidance on setting up and configuring Microsoft SharePoint Server 2013 and the Workflow Manager Client 1.0 server, see Start: Set up and configure SharePoint 2013 Workflow Manager.

As with previous versions, Microsoft SharePoint 2013 provides two primary workflow development environments for authoring workflows: Microsoft SharePoint Designer and Microsoft Visual Studio. However, what differs from previous versions is that using Visual Studio no longer provides a code-based authoring strategy. Instead, both SharePoint Designer and Visual Studio provide a fully declarative, no-code authoring environment regardless of the development tool you select.

Note Note

As a complement to authoring workflows in SharePoint Designer, you can also use Microsoft Visio 2013 to structure your workflow logic by using Visio 2013 shapes, and then import your logic into SharePoint Designer 2013. For information about using Visio 2013 to author your workflow logic, see Workflow development in SharePoint Designer 2013 and Visio 2013.

Declarative workflows

Let's first be clear what is meant by "declarative" workflows. This term means that instead of being authored in code and then compiled into managed assemblies, the workflow is described (literally) in XAML and then executed interpretively at run time.

The XAML is derived (or inferred) from the workflow building blocks that you manipulate in the Workflow Designer (if using Visual Studio) or SharePoint Designer workflow design surface (or Visio, but more about that later). The building blocks themselves are the visual workflow design objects in the designer toolbox—stages, conditions, actions, events, and so on. The set of tools in the respective toolboxes (Visual Studio or SharePoint Designer) differs somewhat, but the concept of the declarative workflow remains the same.

Among the greatest advantages of the workflow framework in SharePoint 2013 is the ease with which information workers can use the no-code environment of SharePoint Designer to create rich and powerful workflows. Additionally, a high degree of flexibility and customization is available in a declarative authoring environment such as Visual Studio.

Both of these workflow authoring environments—SharePoint Designer and Visual Studio—offer specific advantages and disadvantages. In this section, we explore how to determine which authoring environment best suits your workflow development needs.

Using SharePoint Designer

  • Target users: Information workers, business analysts, SharePoint developers.

  • Difficulty level: Familiarity with SharePoint Designer, including the core workflow components, such as stages, gates, actions, conditions, and loops.

With SharePoint Designer, users can create a workflow that is attached to a list, library, or site using a no-code, text-based designer. Or, they can use the new visual design environment in which graphical elements are arranged on a design surface to represent the logical flow of a business process. SharePoint Designer excels at enabling rapid workflow development by non-technical workers.

Using Visual Studio

  • Target users: Intermediate or advanced software developers.

  • Difficulty level: Familiarity with Visual Studio, including software development concepts such as event receivers, packaging and deployment, and security.

Authoring workflows in Visual Studio provides flexibility to create workflows to support virtually any business process, regardless of its complexity, and allows debugging and reuse of workflow definitions. Perhaps most important, Visual Studio lets developers include SharePoint workflows as part of a broader SharePoint solution or app for SharePoint.

Visual Studio enables developers to create custom actions for consumption by SharePoint Designer, and provides the means to execute custom logic. With Visual Studio, developers can also create workflow templates, which can be deployed to multiple sites.

The following table provides a side-by-side comparison of the features and requirements for using SharePoint Designer and Visual Studio to create SharePoint workflows.

Table 1. Workflow authoring tool comparison

Feature / Requirement

SharePoint Designer

Visual Studio

Allows rapid workflow development

Yes

Yes

Enables reuse of workflows

A workflow can be used only by the list or library on which it was developed. However, SharePoint Designer provides reusable workflows that can be used multiple times within the same site.

A workflow can be written as a template so that after it is deployed, it can be reused and associated with any list or library.

Allows you to include a workflow as part of a SharePoint solution or app for SharePoint

No

Yes

Allows you to create custom actions

No. However, SharePoint Designer can consume and implement custom actions that are created and deployed by using Visual Studio.

Yes. However, be aware that in Visual Studio, the underlying activities, not their corresponding actions, are used.

Allows you to write custom code

No

No

Note Note

This is changed from previous versions. In SharePoint 2013, workflows are declarative only and Visual Studio relies on the visual design surface for workflow development.

Can use Visio Professional to create workflow logic

Yes

No

Deployment

Deployed automatically to list, library, or site on which they were created.

Create a SharePoint solution package (.wsp) file and deploy the solution package to the site (SPWeb).

One-click publishing available for workflows

Yes

Yes

Workflows can be packaged and deployed to a remote server

Yes

Yes

Debugging

Cannot be debugged.

Workflow can be debugged by using Visual Studio.

Important note Important

This feature is not implemented in the current build.

Can use only actions that are approved by site administrator

Yes

Yes

Note Note

This is changed from previous versions. Previously, workflows and actions that were authored by using Visual Studio were code-based and deployed at the farm scope, so administrator approval was not required.

Unlike earlier versions, workflows in SharePoint 2013 are entirely declarative. Built now on Windows Workflow Foundation 4, Visual Studio provides a visual workflow designer surface that lets you create custom workflows, workflow templates, forms, and custom workflow activities entirely in the designer environment. Your workflow is then packaged and deployed as a SharePoint Feature. For information about Feature packaging, see Using Features in SharePoint Foundation.

Perhaps the most significant change for Visual Studio developers is that custom workflows are no longer compiled and deployed as .NET Framework assemblies. Furthermore, SharePoint 2013 no longer uses Microsoft InfoPath forms; instead, forms generation relies on Microsoft ASP.NET forms.

Finally, the Visual Studio workflow project templates have changed. Whereas formerly templates for state machine and sequential workflows were provided, these distinctions are no longer meaningful. Rather, Visual Studio project templates are available in the Visual Studio build provided on your virtual machine (VM).

A great deal of developing SharePoint workflows remains unchanged for the Visual Studio developer. The key sections of the documentation for SharePoint 2010 remain relevant:

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.