To get output of first custom node into dropdown of second node

Hi @MutedJam / @BramKn


The table is output of first custom node. We want the rpa_name from column to be displayed in dropdown of second node. We are getting the table output by querying the database.

In the above mentioned method we need to get the output of first node. so we are directly fetching from database. we are not using any backend API. Please help us how to fetch the data using this method to pass to the parameter.

Thanks

Hi @abhilash

What you need to do inside that code is to make the same query to get that table, but only 2 fields need to stay, one name and one value. Which will be the name shown and the value that is behind it so in your case. rpa_name is the name and rpa_id is the value.
This list of names and values is what should be returned by the loadOptions function. You can simply rename that btw. to something like getRpaInstances for example. Make sure to also change it at the properties set up.

1 Like

Hi @BramKn / @marcus
Thanks for your suggestion we are trying that. But we are confused how we can write the query in items variable. or Please suggest us where we can write query. We need to fetch data from database. We are confused where we can write. I am attaching the screenshot of function for reference. We are getting an error- getinputdata doesnot exits.


Thanks

Hi @abhilash,
I see you were able to use loadOptions to list some dynamic options. Inside your loadOptions method you do not have access to getInputData() by design. So you cannot use your input data as an options list, because in n8n any data can be passed into your InstanceName node, not just the output of your other custom node.

What @BramKn was suggesting above ìs:

  • Take the pgQuery from your first node (where you get your rpas)
  • Move it into your InstanceName loadOptions method

Every time you click the dropdown it will execute your loadOptions method, execute your pgQuery and return the list of rpas as { name: rpa_name, value: rpa_id }

Here are example loadOptions from our Notion Node using the responses of API requests to display them in a dropdown. Instead of doing an API request you execute pgQuery to request your rpas.

2 Likes