The Dictionary variable type, although the concept is not new, is new in Nintex Workflow for Office 365 for those who are more experienced with the on-premise version of Nintex Workflow, which instead of a Dictionary, there was a Collection variable. To move your mind into the concept of the Dictionary, takes a little getting used to when you've being working with the collection (or an array of data). But hopefully this serious of posts will shed some light on the subject and make it a little easier to grasp and utilize in your business processes.
I'm sure most of your have opened a dictionary book before. Remember those things called books? Oh wait, ok... http://www.dictionary.com . You probably know that.
The concept of the dictionary is that in effect it's based on Name/Value pairs. Based on the name, you can pull out the value. The big difference between the Dictionary variable type and the Collection variable type, is that a collection was only able to hold values of the same type. A Dictionary have hold all sorts of different variable types at one type.
So where with a collection, you would have two collections to store data from a query (eg. Country and State), with the dictionary, it's one dictionary variable.
|Collection1 (Country)||Collection2 (State)|
Then, you'd need to use an index to get the appropriate value out of each collection.
The dictionary would look like this:
Then, you just need the Get an Item from a Dictionary and pass it the name "Country" and it will return USA. Easy as cake!!
This is the easiest way to start working with a dictionary. Firstly, go to Variables in the workflow designer and create a new Dictionary variable. Once you have that variable, you can then use the Build Dictionary. This is the action you use to define the Name/Value pairs.
In the above example, we have 3 name/value pairs where we define the Key and the Value (Country, State and Sport), with default values of USA, Utah and Poker.
Once you have the dictionary built, you can then use that throughout the workflow instance, as a place to store and retrieve data.
You use the "Get an Item from a Dictionary" action. With the type of dictionary we have built here, it makes it really easy to be able to get at the data, since you only need to specify the value you want, but the Key name.
In the above screenshot, we are getting the value of the State from the dictionary, and storing it in a text variable.
There are times when you need to get the number of items in the dictionary. In that case, you can use the Count Items in a Dictionary.
The above action will the results in an Integer variable.
To update a value in a dictionary, you can use the Build Dictionary action again. Using this action on the same dictionary will not wipe the dictionary clean. It will simply set the values of the items based on the Keys you provide.
As you can see, we are reusing our "dict" variable, but this time, we're only setting the State items value. This is extremely important, because you can therefore use this dictionary through the workflow, reading and updating the data all over the place.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.