Search code examples
make.comintegromat-apps

Input parameter without the "name" property in custom Integromat app


I am trying to create a dropdown parameter (of type 'select') and it should contain two groups of nested parameters. But, I do not need to pass this top-level parameter to the API. I've tried removing the "name" property of this parameter, but then it doesn't remember the user's choice when the module is opened again. How can I include only the nested field in the request, but not the parent?

[
  {
    "type": "select",
    "label": "Select",
    "options": [
      {
        "label": "A",
        "value": "a",
        "nested": [
          {
            "name": "a",
            "type": "text",
            "label": "a nested"
          }
        ]
      },
      {
        "label": "B",
        "value": "b",
        "nested": [
          {
            "name": "b",
            "type": "text",
            "label": "b nested"
          }
        ]
      }
    ]
  }
]

Solution

  • Adding to Petr Malimánek's answer, if you don't know ahead of time which parameters will need to be removed, you can pass their names as an input parameter, like so:

    function omit(collection, ...fields) {
        const result = {};
            
        for (let key in collection) {
            if (!fields.includes(key)) {
                result[key] = collection[key];
            }
        }
            
        return result;
    }