Create a loop section in your worlflow with SharePoint Designer 2010

OOTB, SharePoint Designer doesn’t offer you the ability to create a workflow with a loop.

Fortunately by manipulating the .oxml file of the workflow, everything become possible !

First take care that SharePoint’s web.config has this line as bellow:

<authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Namespace=”System.Workflow.*” TypeName=”WhileActivity” Authorized=”True” />

Next, you can start to create your workflow as you need replacing the expected loop section by an if condition section and encapsulate your activity inside the if in a section called “while do” or something you can find easily later.

Image

Take care to design your workflow correctly and test it now because after the manipulation, you won’t be able to design the workflow any more because SharePoint Designer can’t display a while in the design view.

Save and publish your workflow.

Close the workflow and go to “all files/workflow/your workflow name” and open its .xoml file with Note Pad.

Image

In the XML file, search the section you have created called “While Do” or something else and modify the content of the section as bellow replacing in-red section:

Image

By the in-red section bellow:

Image

Save the bloc note, click on the file .oxml to open the workflow and Save again. Click No when confirm Save.

Image

Restart SharePoint Designer and open the workflow, Make a Check Errors and Publish.

Image

The workflow is ready to be used. Fortunately if you need to update the workflow you have the make the reverse change again in the .oxml file as you see SharePoint Designer can’t display your workflow loop in design mode :

Image