typeOptions > loadOptions dynamical loading properties: defined outputs clear the result?

I’m currently working on a declarative style custom node and I want to load the options of a property dynamical:

properties: [
    {
        displayName: 'Team ID',
        name: 'teamId',
        type: 'options',
        default: {},
        placeholder: 'Ninox Team (67mm9vc324bM7x)',
        required: true,
        description: 'The ID of the team to access',
        typeOptions: {
            loadOptions: {
                routing: {
                    request: {
                        method: 'GET',
                        url: 'teams',
                    },
                    output: {
                        postReceive: [
                            {
                                type: 'setKeyValue',
                                properties: {
                                    name: '={{$responseItem.name}} ({{$responseItem.id}})',
                                    value: '={{$responseItem.id}}',
                                },
                            },
                            {
                                type: 'sort',
                                properties: {
                                    key: 'name',
                                },
                            },
                        ],
                    },
                },
            },
        },
    }
]

Expected Behavior:

I get the queried options which should changed trough output.postReceive to something like " Team (TeamID) ".

Observed Behavior:

What I get instead is: " ()". It feels like the API result is not getting trough postReceive. (Or I’m using the wrong variables??)

Somehow when I remove output.postReceive I get the expected options, but can’t use them because I cannot map the result properly, so the values of the options are the $responseItem.id.

I’m sure I don’t need to use the rootProperty output pipe, 'cuz the API I’m querying response is just an array llike: [{ "id": "67mm9vc324bM7x", "name": "Test Team" }]

Has anyone an idea? Would love to provide an dropdown instead of a text input. :slight_smile:

Repo

Information on your n8n setup

  • n8n version: 0.192.2
  • Database you’re using: SQLite
  • Running n8n with the execution process: own
  • Running n8n via: npm

I remember running into trouble with loading these options as well when building my own node and switched to a programmatic approach at that point :see_no_evil:

@marcus, do you have an idea by any chance?

Hey @geckse,
we’ve looked into the issue and can confirm that your scenario is not working at the moment. We are looking into improving the loadOption behavior to work with array responses not having a rootProperty. I’ll keep you updated on that.

If you don’t want to wait an alternaitve would be using loadOptionsMethod and making the api request in a typescript function. Here is an example how the HighLevel node does it.

3 Likes