cancel
Showing results for 
Search instead for 
Did you mean: 

Dictionary Part 1 - Manually Creating a Dictionary

Nintex Employee
Nintex Employee
11 15 7,247

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.

What is a Dictionary?

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.

eg,

Collection1 (Country)Collection2 (State)
USACalifornia


Then, you'd need to use an index to get the appropriate value out of each collection.

The dictionary would look like this:

NameValue
CountryUSA
StateCalifornia


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!!

Manually Building a Dictionary


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.

BuildDictionary.png

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.

Reading data from a dictionary

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.

GetItemFromDictionary.png

In the above screenshot, we are getting the value of the State from the dictionary, and storing it in a text variable.


Number of Items in the Dictionary


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.

CountItemsinaDctionary.png

The above action will the results in an Integer variable.

Update a Value in a Dictionary


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.

UpdateDictionaryItem.png

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.

15 Comments
Automation Master
Automation Master

Hi Vadim,

Unfortunately, it does not replace the Collection variable in O365.

Christophe

Nintex Employee
Nintex Employee

Hi Christophe,

Can you please elaborate on that?  The dictionary is definitely different to the collection variable.  What functionality would you like to see?

cheers,

Vadim

Automation Master
Automation Master

Hi Vadim,

Be able to collect data and use all the collection operations

I was just refering to this post

Missing workflow variables – Customer Feedback for Nintex

Regards,

Christophe

burkslm
Nintex Newbie

Like always, great job! I always  love it when people give screenshots. It helps visualize for users of all levels. So in 365, the collection variable will still be there? I can't wait until we get to another version of Nintex!

Nintex Employee
Nintex Employee

Hi Lisa,

Thanks

in O365, we're going to add some more functionality to make it easier to use the dictionary in such a way that it is more like the collection variable.

Vadim

burkslm
Nintex Newbie

Hey Vadim,

Excellent! Keep up the good work.

Lisa

alexjolynintex
Nintex Newbie

Wonderfull Vadim!
Exactly what I needed to send to this partner who were complaining this morning about dictionnaries!

For that, I'll owe you a beer in Chicago!

Nintex Employee
Nintex Employee

I prefer my beer to be clear, no bubbles and made from potatoes, preferably in Russia

dchauhan
Nintex Newbie

Hi Vaidm, Thanks for the informative post. we are relatively new customer of Nintex. Just wanted bit more understanding on how to setup a dictionary variable required to create an exchange online invitation in O365. As per screenshot below the "Required" field is forcing to use "dictionary" or "collection" variable and I am not sure at all how to setup email addresses in dictionary variable. Tried few things but it only causes error in workflow.

The support note says following which to me makes no sense since I never worked with dictionary variable.

Required

To make the calendar item a meeting request, use either Required or Optional to specify the list of required attendees email addresses by selecting a collection or dictionary variable.

Note: Special names (keys) are required for the variable items in the dictionary variable containing email addresses for Exchange Online create calendar item. When defining each variable item in Build Dictionary, enter the following values for the Key field, in sequence: 
"(0)": first variable item
"(1)": second variable item
"(2)": third variable item
and continue incrementing the value by one for each successive variable item.

I would really appreciate if you can help me out with this one. 

Thanks

Digant

Nintex Employee
Nintex Employee

Hey Digant,

take a look here: https://help.nintex.com/en-US/O365/Default.htm#o365/O365WorkFlow/WorkflowActions-INT/ExchangeOnlineC... 

Required

To make the calendar item a meeting request, use either Required or Optional to specify the list of required attendees email addresses by selecting a collection or dictionary variable.

Note: Special names (keys) are required for the variable items in the dictionary variable containing email addresses for Exchange Online create calendar item. When defining each variable item in Build Dictionary, enter the following values for the Key field, in sequence: 
"(0)": first variable item
"(1)": second variable item
"(2)": third variable item
and continue incrementing the value by one for each successive variable item.

rehan9194
Nintex Newbie

Vadim Tabakman

Could you please help me here, as I need to do a docusign template which will populate the metadata from sharepoint to docusign template?
We are using On-Prem version, which has the collection operation as you suggested its same as dictionary variable?
But I couldnt see the how to configure this as I'm missing keys and Types in this and don't know what goes under target collection and other options such as add/remove/etc.
This template in docusign will be quite extensive with around 30-40 columns filling in from sharepoint list with different types (i.e. datetime, Person, text fields, etc.)
How many collection variable do I need?

Nintex Employee
Nintex Employee

Hi Rehan,

a Collection variable is no the same as a Dictionary.  If you have 5 fields in your DocuSign template, you will need 2 collection variables.

The first collection variable contains 5 values, the 5 field names.

The second collection variable should also contain 5 values, these are the corresponding values you want to put in those 5 fields.

Vadim

rehan9194
Nintex Newbie

Thanks Vadim,

So how do I configure the action?

What goes in target collection, Index (I believe I dont need this?), Value (Created By, Manager Name, Status?).

Where do I put the field names?

Collection Variable

Nintex Employee
Nintex Employee

Create 2 Collection variables.

1. collFieldNames

Here I would use a Regular Expression action to do a Split.  Add all the field names, separated by a comma.  Then split by comma and store it in the collFieldNames variable.

2. collFieldValues

Here you will need to populate this variable, with the values that you want to put in the fields you mentioned above.

Vadim

rehan9194
Nintex Newbie

Thanks Vadim looks very positive so far.

Quick questions.

1. I have created 2 collection variable, one for Field Name and another for Field Values. I will add as many fields I want and use expression to split it and store in Field Name variable, do I need separate variable for each value and does this applies to both i.e. Field Name and Field Values? Do you mind showing a quick example?

2. I'm trying to multi-sign the docusign, so one I have the first signature I can save as pdf with signature. Now I need to send the signed pdf to another recipient to sign. As the second user needs to see the sign and notes of first before they sign. I had a solution with doc gen template with signature and saving as pdf and again sending pdf to sign, but the requirement is to use docusign template for better ui and ease. Any suggestion?