How to Access Parent Flow Context in Subflows (Custom Node Library)

Hi everyone,

I’m currently building a set of custom nodes in a shared library, and I’m using the flow context to store a class instance that should be accessible across nodes within the same workflow.

In one of the nodes, I’m doing something like this:

const flowContext = this.getContext('flow');
flowContext.someClassInstance = new ClassInstance();

This works perfectly across other nodes within the same workflow, since they can access the same flow context.

However, when I invoke a subflow as part of the main workflow, the nodes inside the subflow cannot access the flow context that was set in the parent workflow. It seems like the subflow execution has its own isolated context.

Question:

Is there a way to access the parent workflow’s context inside a subflow, especially when working with custom nodes? Or is there a recommended way to share data (like an initialized class instance) across nodes in both parent and subflow workflows?

I’m looking for a clean and reusable approach within a node library.

Thanks in advance!

Depending on concurrency, etc, you might be able to use the getWorkflowStaticData feature to share bits of information with the sub-workflows. Generally though, you’d just define the input of the When Executed by Another Workflow trigger node to receive context information directly from the “calling” (parent) workflow.

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