javascriptzapierzapier-cli

Zapier static dropdown displays message regarding loading more options


I have this code for Zapier search action:

      {
        key: 'field0',
        label: 'Field 0',
        required: true,
        choices: { field1: 'Field1', field2: 'Field2' },
        altersDynamicFields: true,
      },
      function (z, bundle) {
        if (bundle.inputData['field0'] === 'field1') {
          return [{ 
            key: 'field1',  
            type: 'string', 
            required: true, 
            label: 'Field1' 
          }];
        }
        if (bundle.inputData['field0'] === 'field2') {
          return [{ 
            key: 'field2', 
            type: 'string', 
            required: true,
            label: 'Field2' 
          }];
        }
        return [];
      },
    ]

It works as expected - renders field based on user selection, however above the dropdown options I see this message:

We couldn't find any more choices.
Sorry, there are no more choices. We've loaded all 2.

How do I get rid of this message?


Solution

  • Try to use case switch control instead.It looks cleaner and will not give any warning errors.

    field = bundle.inputData.field0
     switch (field) {
              case "field1":
                  return [{ 
                key: 'field1',  
                type: 'string', 
                required: true, 
                label: 'Field1' 
              }];
                case "field2":
                  return [{ 
                key: 'field2',  
                type: 'string', 
                required: true, 
                label: 'Field2' 
              }];
                  default:
                return [];
            }