How to perform Looping Through List Items in SharePoint 2013 Designer Workflows

sharepointsharepoint-designersharepoint-workflow

I am new to SharePoint. I'm creating a workflow in SharePoint 2013 in which I want to iterate a List using a loop.
How to perform looping through list items in SharePoint 2013 Designer Workflows?

Best Answer

I'm not aware that there's any out-of-box way to get a workflow to "loop through" all entries in a list, but you can try to make two workflows bouncing back to each other until all entries are updated, here is the detailed steps,

  1. assuming that the list that we are working on is named list_work, in this list, create a column named e.g. cargo

  2. define another list, name it e.g. list_control,

    • define a column named e.g. listID,
    • define a column named e.g. cargo,
    • create one entry in the list, set the cargo to a value.
  3. define a workflow, name it e.g. workflow_list_control, which is triggered every time the entry in list_control is updated, and in this workflow,

    • search for an entry in the list_work where the list_work.cargo doesn't equal list_control.cargo
    • if any entry is found, update the entry of list_work and set the list_work.cargo with list_control.cargo, in order to trigger the workflow_list_work (see #4 below)
    • if no entry is found, stop this workflow.
  4. define the workflow that needs to be run on the list_work, e.g. named workflow_list_work, make it's triggered every time the entry in list_work is updated, and in this workflow, make sure it updates the only entry in the list_control with the ID of the entry from list_work that is being modified, only to trigger the workflow_list_control. In this step, try to put a workflow step to wait and verify the ID is properly updated, in order to allow enough time for the previous workflow_list_control properly finishes.

Every time if a looping-through is necessary, modify the entry in list_control with a different value in the cargo field.

Also refer to calculated-column-to-retrieve-total-number-of-id

Related Topic