SharePoint 2013 Workflow - Working with Dynamic Values

Discover the benefits of using DynamicValue data type and HTTP activities in SharePoint 2013 workflows for seamless service integration.

This page was originally published here ▶️ SharePoint 2013 Workflow - Working with Dynamic Values .

In my last post about workflow in SharePoint 2013 , I mentioned this new data type called DynamicValue. This new data type, in combination with the new HTTP activities, makes it so much easier to work with services in SharePoint 2013 workflows. What Microsoft has given us are a few new activities that you use to acquire, create and parse these data types. Here’s a high-level how it works:

Scenario Overview

You have a workflow that needs to collect the description of a category used in an item. When the workflow starts it gets the category name and calls an OData service to get the description of the category. It then takes the response and saves it to the list item.

Step 1: Create the Variable

In the new Visual Studio 2012 workflow designer, you’ll find something at the bottom that sales Variable. Use that to create a new variable using the data type DynamicValue (full name: Microsoft.Activities.DynamicValue)… I’ll call it CategoryDVResponse. I also create two more string variables named CategoryName and CategoryDescription. These are simply used to call the OData service and save the extracted results after parsing the returned value.

SharePoint Dynamic Value

SharePoint Dynamic Value

Step 2: Call the OData Service

Use an activity LookupCurrentSPListItemString to pull the category name from the list item you’re using to trigger the workflow. Then, use a HttpGet activity to call the service. There are lot of properties you can set on this, but you’re really only interest in two of them… set the values of these two properties to the following:

SharePoint Dynamic Value

SharePoint Dynamic Value

Step 3: Parse the Results & Write to the List Item

Last step is to parse the response from the OData service and write the result to the list item. Use a GetDynamicValueProperty<> activity to parse the results. The following picture shows what it would look like. Basically what you do is you give this activity the variable to parse, the variable to store the result in and the thing to extract (called PropertyName). You’ll write this in XPATH notation since you’re effectively pulling something out of a JSON result.

SharePoint Dynamic Value

SharePoint Dynamic Value

Step 4: Test!

Deploy the workflow and attach it to an announcement list to test it. The following picture shows I’ve entered a category called Beverages.

SharePoint Dynamic Value

SharePoint Dynamic Value

When I run the workflow notice that the body field has been updated with a new category description. Also notice that it says the workflow was updated by Workflow on behalf of a user (this is because Windows Azure Workflow is treated as an app and has been given permissions to do work on behalf of the user when you ran it).

SharePoint Dynamic Value

SharePoint Dynamic Value

If you want to see this in action, check out video #5 from my MSDN video from the Developer Training Workflow module . What I described above is similar to what I did in the video.

Andrew Connell
Developer & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a web & cloud developer with a focus on Microsoft Azure & Microsoft 365. He’s received Microsoft’s MVP award every year since 2005 and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s the founder of Voitanos and is dedicated to helping you be the best Microsoft 365 web & cloud developer. He lives with his wife & two kids in Florida.

Share & Comment