0 / 0
Getting information about nodes

Getting information about nodes

Nodes fall into a number of different categories such as data import and export nodes, model building nodes, and other types of nodes. Every node provides a number of methods that can be used to find out information about the node.

The methods that can be used to obtain the ID, name, and label of a node are summarized in the following table.

Table 1. Methods to obtain the ID, name, and label of a node
Method Return type Description
n.getLabel() string Returns the display label of the specified node. The label is the value of the property custom_name only if that property is a non-empty string and the use_custom_name property is not set; otherwise, the label is the value of getName().
n.setLabel(label) Not applicable Sets the display label of the specified node. If the new label is a non-empty string it is assigned to the property custom_name, and False is assigned to the property use_custom_name so that the specified label takes precedence; otherwise, an empty string is assigned to the property custom_name and True is assigned to the property use_custom_name.
n.getName() string Returns the name of the specified node.
n.getID() string Returns the ID of the specified node. A new ID is created each time a new node is created. The ID is persisted with the node when it's saved as part of a flow so that when the flow is opened, the node IDs are preserved. However, if a saved node is inserted into a flow, the inserted node is considered to be a new object and will be allocated a new ID.

Methods that can be used to obtain other information about a node are summarized in the following table.

Table 2. Methods for obtaining information about a node
Method Return type Description
n.getTypeName() string Returns the scripting name of this node. This is the same name that could be used to create a new instance of this node.
n.isInitial() Boolean Returns True if this is an initial node (one that occurs at the start of a flow).
n.isInline() Boolean Returns True if this is an in-line node (one that occurs mid-flow).
n.isTerminal() Boolean Returns True if this is a terminal node (one that occurs at the end of a flow).
n.getXPosition() int Returns the x position offset of the node in the flow.
n.getYPosition() int Returns the y position offset of the node in the flow.
n.setXYPosition(x, y) Not applicable Sets the position of the node in the flow.
n.setPositionBetween(source, target) Not applicable Sets the position of the node in the flow so that it's positioned between the supplied nodes.
n.isCacheEnabled() Boolean Returns True if the cache is enabled; returns False otherwise.
n.setCacheEnabled(val) Not applicable Enables or disables the cache for this object. If the cache is full and the caching becomes disabled, the cache is flushed.
n.isCacheFull() Boolean Returns True if the cache is full; returns False otherwise.
n.flushCache() Not applicable Flushes the cache of this node. Has no affect if the cache is not enabled or is not full.
Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more