SharePoint 2013 Workflow with Visual Studio 2012

3 minute read

Today I have been working on a project that required a workflow in order to keep track of a status. Because we were working with SharePoint 2013 I thought lets build a SharePoint 2013 Workflow.

First of all when you would like to begin using SharePoint 2013 Workflow you have to install some services. When using the Web Platform Installer it is quit easy. When you still need to install SharePoint 2013 workflow following the below article from Microsoft:

When you want to start with developing SharePoint 2013 workflows you will also have to install a Extension for Visual Studio:

  • Workflow Manager Tools 1.0 for Visual Studio 2012

When creating my first workflow for Visual Studio 2012 I noticed that I was missing a .cs file so I started to read some articles on MSDN:

The following line got my attention.

“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.”

Basically this will mean you can only create your workflow declarative. When you need to write custom code you will have to build a custom action:

When I was creating my first workflow the second thing I noticed was that there are a lot of actions you use and that it is quite easy to extend:

image

All together I think this new approach is very powerful and does also mean you will be able to create APP workflow.

Deploying my first workflow directly resulted in a error when activating the feature:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Microsoft.SharePoint.SPException: App Management Shared Service Proxy is not installed.
   at Microsoft.SharePoint.AppRegistration.GetProxy(SPServiceContext serviceContext)
   at Microsoft.SharePoint.AppRegistration.AddOrUpdateAppNoPermissionCheck(SPAppPrincipalInfo appInfo)

You will have to create a App Management Service Application if you want to run SharePoint 2013 workflow and off course also start the “App Management Service“. Besides that the “Microsoft SharePoint Foundation Subscription Settings Service” should be started and you also have to make the Service Application by using PowerShell.

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$account = Get-SPManagedAccount devdevservice
$appPool = New-SPServiceApplicationPool -Name SubscriptionServiceAppPool -Account $account 
$serviceApp = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPool -name "Subscription Settings Service Application" -DatabaseName "SP2013_DEV_SubscriptionSettingsDB" 
$serviceAppProxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $serviceApp

One other thing I noticed is that the workflow feature will have to be a Web scoped features. You should keep this in mind when designing your solutions.