Creating Loops in SharePoint Designer 2010 Workflows

By default SPD 2010 does not allow possible infinite loops to be added to a workflow. Here is the guide how you can do it:

  1. Open SPD 2010
  2. Add a new Workflow
  3. Add new IfElseActivity and fill in the conditions and the actions you want to loop through
  4. Save the workflow
  5. Go to Alle Files -> Workflows -> Your workflow name  folder and open  “your workflow name.xoml” file as xml.
  6. Locate the lines that look like this:

<IfElseActivity x:Name="ID411">

<IfElseBranchActivity x:Name="ID412">


<RuleConditionReference ConditionName="__Rule_ID412" />


And replace if with something like this:

<WhileActivity x:Name="ID411">


<RuleConditionReference ConditionName="__Rule_ID412" />



Keep in mind that you have to remove also the ending tag of the IfElseBranchActivity.  Keep also in mind that if you have multiple activities in the IfElseActivity taht you have to encapsulate these activities into one single SequenceActivity.

Now you can Publish your workflow back to SharePoint.

One drawback of this approach is that SPD does not support designing of a whileactivity in the worklow designer so you have to change the activities direct in the xoml file or you can replace the whileactivity again with ifelseactivity, do your changes and replace it again.

You have to also modify the web.config of the web app where you want to deploy your workflow because by default is the WhileActivity disabled. Locate following line

<authorizedType Assembly="System.Workflow.Activities, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Workflow.*" TypeName="WhileActivity" Authorized="False" />

and set the “Authorized” attribute to True.


Tags: , , ,

16 Responses to “Creating Loops in SharePoint Designer 2010 Workflows”

  1. SharePoint 2010: Recopilatorio de enlaces interesantes (XIII)! « Pasión por la tecnología… Says:

    […] Creating Loops in SharePoint Designer 2010 Workflows […]

  2. SharePoint 2010: Recopilatorio de enlaces interesantes (XIII)! - Blog del CIIN Says:

    […] Creating Loops in SharePoint Designer 2010 Workflows […]

  3. zula Says:


    I did your tutorial and when I publish the workflow get this error: “(0, 0) Activity ‘ID4’ validation failed: WhileActivity should have one child activity.)”.
    Can you help?



    • vojtan Says:

      Hi Carlos.
      I think that you have multiple activities under the whileactivity. You have to encapsulate these activities with one SequenceActivity


  4. zula Says:

    Hi Vojtan,

    i do what you say to me, but when i open again th workflow in SP Designer 2010 doesn´t appear anything. This is normal?



    • vojtan Says:

      Yes this is normal. The SharePoint Designer 2010 is not able to display the while activity. Sorry for the late responce.

  5. Erica Says:


    Once I make changes to the code within the workflow, I am no longer presented with the option to Publish. Is there another way i can go about doing this?
    Thank you!

    • vojtan Says:

      Hi. Are you sure that the xml syntax is correct? Can you validate the workflow syntax? I did not have this problem.

      • Erica Says:

        Per your request:

        When I go to the workflow settings where you can edit using SP Designer controls, it says that SP Designer is unable to display the item, which I understand. It’s just that this is where I go to publish the workflow, that option is not available. Is there another way i can go about doing this?

        Thank you in advance for any help you can provide with this.

      • Erica Says:

        Syntax did not post in previous posting:

    • vojtan Says:

      As far as I can remember the sharepoint designe does not display any messages when you add the while activity. It just does not display the activity.

  6. Jasper Says:

    Hi Vojtan,
    Do you have a small example? Forinstance: do you need a closing tag?
    And the sequence activaty where do you place the WhileActivity withing?


    Thanks in advance.

    • vojtan Says:

      Yes you need a closing tag. Locate the /IfElseActivity tag and replace it with /WhileActivity tag. The sequence activity remains within the WhileActivity and /WhileActivity tags. HTH

  7. Pule Babie Says:

    Works beautifully . . . Thanks mate!

  8. Mai Wafik Says:

    Update… After editing the .xoml file and placing “The sequence activity within the WhileActivity and /WhileActivity tags.” as mentioned… no errors in publishing.. but the workflow itself fails on start.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: