RPC running before required field is filled

I need to pull multiple dynamic fields into my module settings via the RPC system.

My issue is that the RPC request relies on the ‘step_id’ field that the user should be entering manually in the form, but if I make the ‘step_id’ field required in the RPC parameters, I get a ‘Bad Request’ error immediately upon module loading:

Important note: This error has nothing to do with my API because it’s not being hit, the error is some kind of Make validation error before hitting my API.

Here is my RPC code:

{
  "url": "/make_step_schema/",
  "method": "GET",
  "qs": {
    "id": "93", // hard-coded ID (not a valid solution)
    "api_key": "{{connection.apiKey}}"
  },
  "response": {
    "iterate": "{{body}}",
    "output": {
      "name": "{{item.name}}",
      "label": "{{item.label}}",
      "type": "{{item.type}}",
      "options": "{{item.options}}"
    }
  }
}

And my RPC Parameters:

[
  {
    "name": "step_id",
    "label": "Step ID",
    "type": "text",
    "required": false // I get the "Bad Request" error when this is 'true'
  }
]

To make it work right now, I need to set required: false and hard-code my step_id value to a valid ID, which allows the module to successfully load the dynamic fields.

However this ID must be dynamic, and therefore must be required and entered BEFORE the RPC request happens, or at least re-run when they enter a new ID.

Is there a mechanism for this that I’m missing?

I saw the info about ‘nesting’ for select dropdowns, etc but this is not a select dropdown, so I couldn’t figure out how to apply that to my situation.

Thanks for any help!

I’ll just leave this here for anyone who finds this in the future.

I don’t think it’s possible to do what I was hoping for, but fortunately my ‘step_id’ field actually does make sense to be turned into a dynamic select dropdown fetched from my server, which enabled me to use the ‘nesting’ feature, like this:

[
    {
        "name": "step_id",
        "type": "select",
        "options": {
            "store": "rpc://getSteps",
            "nested": [
                {
                    "name": "data",
                    "label": "Data",
                    "type": "collection",
                    "spec": [
                      "rpc://getFields"
                    ]
                  }
              ]
            } ,
        "label": "Step",
        "required": true
    }
]
3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.