8-Week Microsoft Teams AppDev Accelerator Program
Limited seats available! - Start date: Wednesday, April 16, 2025
Join Today & Save $1,000
articles

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.

SharePoint 2013 Workflow - Working with Dynamic Values
by Andrew Connell

Last updated July 17, 2012
3 minutes read

Share this

Focus Mode

  • Feedback & questions

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

Andrew Connell, Microsoft MVP, Full-Stack Developer & Chief Course Artisan - Voitanos LLC.
author
Andrew Connell

Microsoft MVP, Full-Stack Developer & Chief Course Artisan - Voitanos LLC.

Andrew Connell is a full stack developer who focuses on Microsoft Azure & Microsoft 365. He’s a 20+ year recipient of Microsoft’s MVP award and has helped thousands of developers through the various courses he’s authored & taught. Whether it’s an introduction to the entire ecosystem, or a deep dive into a specific software, his resources, tools, and support help web developers become experts in the Microsoft 365 ecosystem, so they can become irreplaceable in their organization.

Feedback & Questions

newsletter

Join 10,000+ developers for news & insights

No clickbait · 100% free · Unsubscribe anytime.

Subscribe to Andrew's newsletter for insights & stay on top of the latest news in the Microsoft 365 Space!
blurry dot in brand primary color
found this article helpful?

You'll love these!

SharePoint 2013 - What's new with SharePoint Workflow

SharePoint 2013 - What's new with SharePoint Workflow

July 17, 2012

Read now

SharePoint 2013 (Public Beta) - Everything You Need to Know

SharePoint 2013 (Public Beta) - Everything You Need to Know

July 16, 2012

Read now

SP2013 WCM: Forget Everything You Knew About SharePoint WCM

SP2013 WCM: Forget Everything You Knew About SharePoint WCM

July 16, 2012

Read now

bi-weekly newsletter

Join 10,000+ Microsoft 365 full-stack web developers for news, insights & resources. 100% free.

Subscribe to Andrew's newsletter for insights & stay on top of the latest news in the Microsoft 365 ecosystem!

No clickbait · 100% free · Unsubscribe anytime.

Subscribe to Andrew's newsletter for insights & stay on top of the latest news in the Microsoft 365 Space!