Partager via


SharePoint 2013 Designer Workflows Using Call HTTP Service to retrieve choice column values

In SharePoint 2013 the Call HTTP Service action is a very powerful addition to the the repertoire of functionality provided by SharePoint Desinger Workflows.

It is a convenient way to add extra functionaly to SharePoint Designer workflows ( by delegating work to a remote web service). Apart from that I enjoy the extra flexibility it provides by calling the REST services provided by SharePoint to retrive values from lists/libraries.

I recently had to develop a workflow in SharePoint to allow Managers to assign tasks to team members from a pre-defined list of tasks. These tasks are stored as the items in a multi select choice column as shown in below screenshot.

For this I need to retrieve the selected items in the multi select choice column in the SP Designer workflow. I found out that the Call HTTP action was the easiest way to implement this requirement.

Most of you might have tried calling the SharePoint REST services from SP Desinger workflows already.

You have to use the Build Dictionary variable and add two items to the dictionary named Accept and Content-type as shown in the screenshots.

               

The Call HTTP Web Service action has to be added after this. Then right click the action and select properties, and set the request header to the Dictionary variable which was built in the previous step as shown in the screenshot.

In my case I am retrieving values from a SharePoint List which has a multi select choice column and I need iterate through the items to retrieve the values which were selected for each item.

Therefore we need to choose HTTP GET as the HTTP method and specify the list, and filter specifications. Selecting specific columns will reduce the amount of data that is returned from the call.

As shown in the screenshot 'Tasks Assigned' is the multi select column. To retrieve the values of just this particular column from all the other data that the REST call returns, we need to use the 'Get an Item from a Dictionary' action.

Getting the values for the multi select column was the part where I struggled because the on the browser the data is returned in ATOM format and not in JSON.

For this I used Fiddler. Before starting a new capture, click on the Filters tab and Select Use Filters.

In the Request Headers section, select Set request header and enter the header as application/json;odata=verbose.

Now browse to the SharePoint REST url and refresh the page, this allows you to download the feed in the JSON format.

Open this file using JSON viewer, this enables you to view the correct path that needs to be used in the Get an Item from a dictionary action as shown in the below screenshot.

The same path can be used in the Action as shown below.

The count of the items selected in the multi select column can be obtained using the Count items in Dictionary action.

I created a loop that loops till the value of the count and inside the loop I use the 'Assing a Task' action to assign the task to team members.

The complete workflow can be seen in the below screenshot.