SharePoint 2013 Designer workflows now has two new interesting options: the ability to call HTTP web services and the option to loop over some code a number of times. This, together with the new REST API, which supports querying lists and returning data in JSON, allows iterating through list items in a workflow, something that was not possible before.

In order to demonstrate this, let’s create a new Site Workflow in SharePoint Designer, that will iterate through the Tasks list.

Call it Process Tasks, for example, and make sure you select SharePoint 2013 as the platform type.

In the workflow designer, let’s start by creating a new stage, call it Retrieve Tasks:

In it, we add a new Set Workflow Variable action which creates a new String variable called url with the value “http://sp2013/_api/web/lists/getbytitle(‘Tasks’)/items”. This uses the new REST API, and you can pass in additional options, such as for ordering by the DueDate field in descending order:

http://sp2013/_api/web/lists/getbytitle(‘Tasks’)/items?$orderby=DueDate desc

or filtering:

http://sp2013/_api/web/lists/getbytitle(‘Tasks’)/items?$filter=DueDate gt DateTime’2017-07-31T00:00:00’

or paging:

http://sp2013/_api/web/lists/getbytitle(‘Tasks’)/items?$top=20

Next, we add a Dictionary variable (Build a Dictionary action), call it requestHeaders, and initialize it as this: