Task List types in SharePoint Online and how to use them in SharePoint Designer workflows

If you are still working with SharePoint Designer workflows, you will be familiar with a setting that has to be made for each workflow: the associated Task list.
Strangely, you need to set this even if your workflow isn’t creating any tasks.

If you open the Task list drop-down, SharePoint Designer will propose the available task list – if any are available – and an option to create a new Task list.

tasklistdropdown

As you will probably know, there are two platform types available in SharePoint Designer 2013: you can create SharePoint 2013 workflows and you can still create SharePoint 2010 workflows. The latter option is still very relevant, because several useful functions like creating a copy of a document only exist in SP2010 workflows.

While working on a SharePoint Online site which has both SP2010 and SP2013 workflows, I noticed a difference in the Task lists that were being offered in the dropdown, which I couldn’t explain at first.

Then it dawned on me: SharePoint 2010 workflows come from the age of SharePoint 2010 (obviously). If you would create a Task list through the browser in SharePoint 2010, you get a different Task list compared to the one that you create through the browser in SharePoint 2013!
As a result, if you create a SharePoint 2010 workflow (in SharePoint Designer 2013) and a SP2010-style Task list is available, that is the one the dropdown will offer you.
A SharePoint 2013 workflow on the other hand will offer you both the SP2010 and SP2013-style Task lists.

You can use a SP2010 workflow with a SP2013-style Task list, but that has another nasty side-effect: the Task list is then automatically populated with a number of old-school content types, like “SharePoint Server Workflow Task” (yes, even in SharePoint Online), and all of the fields that come with it.

Another unpleasant side-effect: the SP2013 version of the Task list has several additional options, like displaying a timeline and a strikethrough option for completed tasks. But if you associate a SP2010 workflow with a SP2013-style Task list, some of those options will not work anymore (found this out the hard way).

So how do you handle this? If you have both SP2010 and SP2013 SharePoint Designer workflows on your site, my recommendation is that you create two Task lists:

  1. a SP2010-style Task list for the SP2010 workflow tasks
  2. a SP2013-style Task list for the SP2013 workflow tasks

That way each workflow gets the appropriate Task list capabilities.

Now here’s the trick: if you create a Task list through the browser in SharePoint 2013 or above – so also in SharePoint Online – you will always get the SP2013-style Task list.
The SP2010-style Task list is still available though, but you will need to create the list through script.
The main distinction to remember:

  • SP2010 Task list = TemplateType 107
  • SP2013 Task list = TemplateType 171

So now you can do something like this in CSOM:

#get the context (request the site, user and password parameters from the user)
$context = New-Object Microsoft.SharePoint.Client.ClientContext($site)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($user, $password)
$context.Credentials = $credentials

#now we can prepare the new list object
$listCreationInformation = New-Object Microsoft.SharePoint.Client.ListCreationInformation
$listCreationInformation.Title = “My Old School SP2010 Task List”
$listCreationInformation.Description = “My Old School SP2010 Task List”
$listCreationInformation.TemplateType = 107

#then we create the list in our web site context
$list = $context.Web.Lists.Add($listCreationInformation)
$context.Load($list)
$context.executeQuery()

And voila, you have a custom-made SP2010-style list in your SharePoint Online site.
The SP2013-style list can obviously be created in the same way, or through the browser if you like.

Advertisements