Nick Grattan's Blog

About Microsoft SharePoint, .NET, Natural Language Processing and Machine Learning

Archive for the ‘SharePoint Workflows’ Category

While loops in SharePoint Designer 2013 Workflows

with 2 comments

Two types of workflows are available in SharePoint 2013:

The good news is when running SharePoint 2013 Workflows you can create while loops in SharePoint Designer 2013 workflows. Here’s how they look.

Once you’ve opened a site and a list in SharePoint Designer 2013 you can create a new List Workflow:

 

The “Create List Workflow” dialog allows you to select the platform for the workflow – you must select SharePoint 2013 Workflow to enable the loop option:

Now the ribbon will display a new button “Loop” with two available loop:

And so loops can now be added to the workflow:

Joy of joys!  Of course, enabling while loops in SharePoint Designer 2010 is much more difficult – you can find one solution here:  https://nickgrattan.wordpress.com/2010/12/14/while-loops-in-sharepoint-designer-workflows/

 

 

Written by Nick Grattan

July 22, 2012 at 4:40 pm

While loops in SharePoint Designer Workflows

with 29 comments

When implementing processes, we’re often faced with creating workflows that require something like “while not approved, ask document to be edited and re-approved”. This is difficult to do with SharePoint Designer workflows as it requires looping.

For a while now I’ve been using our Custom Workflow Activity Pack to create loops in SharePoint designer. This simulates a state workflow and is described here: Stateful Workflow Paper. This approach works, but is cumbersome and involves a number of moving parts. A “While Workflow” custom action has now been added that greatly simplifies doing this. This custom action takes four arguments:

  • A field in the document library or list with which the workflow is associated.
  • A condition to test (e.g. “equal to”, “greater than”).
  • A value to test against (either a constant or a lookup to another value in the list, a workflow variable or value from another list)
  • The workflow to call to create the loop. This workflow will be repeatedly called while the expression in the first three arguments returns false.

In this example, a document library has two fields “Verified” (Yes/No) and “Verify Comments” (Single line text). Two workflows need to be created:

  • A workflow (e.g. named “Verify Document”) that contains the task that is to be repeated
  • Another (e.g. named “While Not Verified”) workflow that repeatedly calls the first workflow until the task is completed successfully.

The first workflow, “Verify Document” in this example, simply creates a task requesting the user to verify the document. After the task is completed the “Verified” field is updated in the document library:

whileloop1.PNG

The second workflow uses the “While Workflow” custom action to create the loop. This will repeatedly call the “Verify Document” workflow until the document is verified.

whileloop2.PNG

You can download the latest version of the Custom Activity Pack here. A SharePoint solution file (WSP) is now provided to automate installation. If you already have a previous version installed, follow the instructions in the documentation to uninstall the previous version first.

Download Custom Activity Pack.

Update: See here how while loops are now directly supported in SharePoint 2013: https://nickgrattan.wordpress.com/2012/07/22/while-loops-in-sharepoint-designer-2013-workflows/

Update: 10-Nov-2013. Source code and WSP now available in GitHub: https://github.com/NickGrattan/NGCCustomActivities.git

Written by Nick Grattan

December 14, 2010 at 7:09 am

Creating While Loops in SharePoint Designer Workflows using Stateful Workflows – Part 2

with 3 comments

Here’s some additional information to this post about this subject.

An alternative to our solution for while loops in SharePoint Designer workflows have been previously proposed based on setting a workflow to start when an item is changed. This gets over the problem of how to get a workflow to restart itself (which we do with the “Restart This Workflow” action). You can find a description of how to do this here: http://sharepointmagazine.net/technical/development/the-dog-ate-my-task-use-sharepoint-designer-to-email-daily-task-reminders

However, the technique of a workflow restarting itself when an item changes will not work with SP2. Take a look at this Microsoft post:

http://blogs.msdn.com/sharepointdesigner/archive/2009/07/13/service-pack-2-prevents-an-on-change-workflow-from-starting-itself.aspx

In SP2 a workflow cannot restart itself recursively, and so this will break stateful workflows written in this way. Seems strange that Microsoft would introduce a breaking change when using these techniques have been well documented.

Written by Nick Grattan

October 7, 2009 at 12:40 pm

Creating While Loops in SharePoint Designer Workflows using Stateful Workflows

with 14 comments

For an update on this topic please see this blog entry: https://nickgrattan.wordpress.com/2010/12/14/while-loops-in-sharepoint-designer-workflows/

Amongst several significant limitations with SharePoint Designer workflows, perhaps the most important is the lack of looping. Therefore, expressing processes like “while not approved, rework” becomes difficult.

We have published a paper that describes how to implement while loops by emulating stateful workflows in Microsoft SharePoint Designer. You can download the paper here (PDF, Oct 2009). The technique uses our “Restart this workflow” custom action, which is part of our “Custom Activity Pack” which can be downloaded here for free.

Update: 10-Nov-2013. Source code and WSP now available in GitHub: https://github.com/NickGrattan/NGCCustomActivities.git

Written by Nick Grattan

October 6, 2009 at 10:00 am

Custom Workflow Action: Send to Records Center

with 7 comments

Our Custom Activity Pack contains actions that can be installed for use in Microsoft SharePoint Designer workflows. The latest version includes an action for sending documents and items to a Records Center site collection directly from your workflows.

The Custom Activity Pack is free and can be downloaded from GitHub: https://github.com/NickGrattan/NGCCustomActivities.

Other custom actions in this pack include:

  • Start Workflow – Start another workflow for the item or document and return.
  • Call Workflow – Start another workflow and wait until that workflow has completed.
  • Halt Workflow – Halt another workflow executing against the item or document.
  • Restart This Workflow – great for implementing stateful workflows in SharePoint Designer
  • Is Workflow Running – check if another workflow is running against the item or document.

Here is the entire list of actions:

CustomActivities.png.PNG

Written by Nick Grattan

October 1, 2009 at 5:18 pm

Changing the Task list for SharePoint Designer Workflows

with 15 comments

By default, SharePoint designer will automatically select an existing Task list or create a new one if a suitable Task list does not exist. To change the Task list being used:

  1. Create a new Task list using Site Actions + Create.
  2. Find the Id (Guid) for this new list following the technique described in my blog entry here.
  3. Using SharePoint Designer, open the site where the workflow exists, expand out the “Workflows” folder and the workflow whose Task list is to be changed.
  4. Locate the file called workflowname.xoml.wfconfig.xml and open this file for editing.
  5. Take the Id found in (2) above and replace the Id in the “<Association>” element’s “TaskListID” attribute.
  6. Save the file.

 

Written by Nick Grattan

April 29, 2008 at 11:32 am

Microsoft SharePoint Designer Workflows – Things is doesn’t do

with 11 comments

Creating workflows with the Microsoft SharePoint Designer is quick and simple. However, there are number of distinct limitations which you need to be aware of, such as:

  • Workflows have no looping or flow control statements. Workflows execute serially from the top to the bottom. Implementing flows such as “continue executing until approval is made” becomes problematic.

Update 25 Nov 2009: See this post for how while loops can be simulated using stateful workflows with Microsoft SharePoint Designer.

  • Workflows can only be associated with lists, not content types. This can be limiting when you allow, for example, users to select one of a number of InfoPath forms on the “New” menu and you want different workflows depending on the type of document created.

Update 25 Nov 2009: You will have to wait until SharePoint Designer 2010 and SharePoint 2010 for this!

  • Workflows are associated with a single list. You can, though, using the technique described here copy them to other lists.

This list doesn’t include limitations in the standard actions provided by Microsoft SharePoint designer – custom actions written in Visual Studio can help in this case.

Written by Nick Grattan

April 14, 2008 at 3:08 pm