Best answer

Documentation for The Dictionary Inputs

  • 26 February 2021
  • 6 replies
  • 1066 views

Userlevel 1

The documentation for setting up Dictionary type inputs in the Zapier CLI does not seem to provide how to implement them with the other inputs for Field mapping. I am receiving errors when attempting to set up and test the dictionary field in my Zap. Any examples of an active Dictionary input set up in the CLI/Clarifying documentation would be greatly appreciated.  

icon

Best answer by ikbelkirasan 26 February 2021, 18:35

View original

6 replies

Userlevel 7
Badge +12

Hi @RobertPRollick - Dictionary input fields are basically Key-Value pairs of strings. When building with the CLI, they can be configured by adding dict: true to your input field configuration.

For example:

{
"key": "metadata",
"Label": "Metadata",
"dict": true
}

In this example, you can reference this as bundle.inputData.metadata. which will give you an object of key-value pairs. Both the keys and the values are strings.

Userlevel 1

@ikbelkirasan I understand that but it looks like if the dictionary type is set up through the UI, that multiple fields can be added as needed by whoever is using the zap https://platform.zapier.com/docs/input-designer (talking about the + sign in the dictionary section). Whereas when I set this up in the CLI it is only capable of setting up one field that I have to supply the key and Label for. 

Userlevel 7
Badge +12

@RobertPRollick - That’s strange and I’m not sure why you’re seeing this behavior. I went ahead and tested with the CLI adding that metadata input field I mentioned above and here’s what I got. Seems to be working as expected. So, can you show me what your dictionary field configuration looks like? 

 

 

Userlevel 1

@ikbelkirasan I had the dict attribute before the key and label. Looks like that was causing the issue. Is there documentation on how to parse through the collected pairs or does it act as an associative array? 

Userlevel 7
Badge +12

@RobertPRollick - The collected pairs are provided to the handler function as a JavaScript Object.

For example:

bundle.inputData.metadata value would be:

{
"key1": "value1",
"key2": "value2"
}

 

Userlevel 1

@ikbelkirasan Thank you for your quick response!

Reply