Access other node parameter in loadOptions

Hi, Happy new year
Hope you all are doing great.

I have a question: How can I access other node parameters in loadOptions method?
As I realized in loadOptions method we can’t reach this.getWorkflow(), and also getNodeParameter only works with the current node not other nodes.
Do you have any idea?

That is sadly not possible and was honestly never needed and so planned to change that. Can you please share your use case.

1 Like

Thanks for your answer @jan .

I have a node that has a parameter which is a type of options. I need to filter that options by another node’s selected option.

In short: my current node parameter options is based on another node selected option.

What about “execute” method? is there any way to get other nodes data that exist in the current workflow?
It seems this.getWorkflow() only returns id and name. I need a method that returns all nodes (defined in the current workflow) as well.

Do you have any idea?

In the “execute” method you can access most data. You can do that via the “WorkflowDataProxy”

const itemIndex = 0;
const proxy = this.getWorkflowDataProxy(itemIndex);
const parameterValue = proxy.$node["nodeName"].parameter["parameterName"];

To make it clearer You can then access everything via the proxy that you can access via Expressions or the Function-Node, as that is what they are using underneath the hood.

Hope that is helpful!

1 Like

Wow great. Thank you very much. Of course it’s helpful :slight_smile:

Glad to hear. Have fun!

1 Like

Dear @jan,

For this line:

proxy.$node["nodeName"]

I must use the name of a node which is mutable, for example “Date & Time”. Is there any way to find the node by the actual node name like “n8n-nodes-base.dateTime” ?

The actual node name is in this case “Date & Time” which is unique in each workflow. What you are asking is to find them by their type (“n8n-nodes-base.dateTime”), of which there could be multiple nodes in a workflow.

Sadly is there currently no way to query nodes by their type.

1 Like

Thank you very much @jan

Sorry to not have had better news…

1 Like

Oh no problem, That’s wonderful :slight_smile: