Best answer

Multiple-entry input fields

  • 24 July 2023
  • 3 replies
  • 448 views

Userlevel 1
Badge

What this the syntax for creating an input field, using the CLI  environment, that allows for multiple values to be supplied?

inputFields: [
{
key: 'FileID',
label: 'File ID',
type: 'string',
helpText: "The IDs of the files to be retrieved.",
required: true,
multiple: true, // ?
list: false,
altersDynamicFields: false,
},
],

When this field is posted, how are multiple values denoted?  A comma-delimited string or an array of strings?

bundle.inputData.FileID = 'A','B'

// OR

bundle.inputData.FileID = ['A','B']

 

icon

Best answer by connorz 24 July 2023, 19:47

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 3
Badge +6

Hey @craibuc ,

Great question!

In the CLI, the relevant property is list

When list: true, the user is able to provide multiple values, and Zapier will store them in an array:

For example, a field like this…

{
key: "fruits",
label: "Fruits",
helpText: "Enter some fruits",
list: true
}

...would present like this in the editor (where a new input appears after each entry)…

 

...and by default, bundle.inputData.fruits would be passed as an array:

["Apple", "Grape", "Watermelon"]

 

Userlevel 1
Badge

If only one value is supplied, is it an array of one item?

Userlevel 3
Badge +6

Hey @craibuc ,

Yes, if only one value is supplied, it’s formatted as an array of one item. 

For example, here...

bundle.inputData.fruits has a value of [ 'Apple' ]