5

I have a dictionary with a series of rates (percentages represented by decimals), one for each day of the week, stored in a Dictionary as numbers each titled by a day of the week. I would like to create a simple loop which takes the base rate from the current item multiplies it by the rate and then updates another field to the calculated rate, then pauses for a day and runs again, but with the next day's rate.

I started by setting the loop to run 7 times. Then my first step was "get item from dictionary" but I don't know how to set the path so it will go to the next item in the dictionary.

Basically how do I get the loop to run through a dictionary and perform the same action on every item?

9

To retrieve value from a dictionary using Get an Item from a Dictionary workflow action you could specify either name or path.

Example

The following example demonstrates how to iterate dictionary and retrieve its value by name.

Assume the dictionary that contains country list as shown on figure below

enter image description here

Workflow

  • CountriesCount variable stores count of countries using Count Items In A Dictionary workflow action
  • Index variable serves as counter
  • CountryKey variable stores current key for a country dictionary

  • CountryName variable stores value retrieved by key from a country dictionary

enter image description here

Result

enter image description here

3

Working with dictionary results in Designer is painful. You have to know the shape of the data. If you know the shape of the data, you could easily identify the path to the part you want. Unfortunately, Designer doesn't make it easy to write the full dictionary to a log for visibility sake. Instead, writing a workflow that returns dictionary results from Call HTTP is a blind REPL.

I have taken to writing the REST queries using JavaScript (fetch api) directly in the browser and inspecting the JSON results to discern the path.

If workflows made it possible log dictionary results in full, this painful extra step would be unnecessary.

You basically have to write the query twice: once for personal visibility and again for the workflow.

1

There has to be a better example than "How to work with dictionaries in SharePoint 2013 and Office 365 workflow", somewhere. The instructions are fine until you get to the part about iteration, then they go completely off the rails.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.