Enhancement request: enable config-nodes to accept msg variables to set config at runtime

Hi

I am using existing nodes (such as which node-red-contrib-mssql-plus) which is using the “standard” ‘configuration node’.

Mostly the configuration points to an external SQL db or ERP/SAP system for which the configuration is setup beforehand (at design time).
The problem is that selecting the configuration also need to happen at design time, where my requirement is for runtime.

My use case is set in a corporate multi plant environment(let say 7 plants), where node-red is used as a integration tool between business systems.
I have 1 common flow that needs to connect to 1 of the 7 plants on-premise manufacturing systems.
The 7 manufacturing systems has the same SQL structure and functionality, the only difference is their data at their respected plant.

Using the SQL connector as an example, I will have a http request that comes in, to update a value on the SQL db of 1 of the 7 plants.
The indication of which plant will come with the http in payload {“plant”:” “Plant 1”}

To satisfy the above use case, I need the pre-configuration (that has already been setup for each plant), to be selected at runtime by for example msg.payload.plant

This can normally be achieved by ‘Typed Inputs’
image

The problem that I have is that config-nodes does not have the functionality of ‘typed inputs’ for configuration elements.

For an existing node I have managed to ‘enhance’ the node to some degree, but my effort still falls short.

This is what I have done.
I have added a Typed Input for a ‘Dynamic Connection’
(My intent was to merge the new Dynamic Connection and the original config-node but I failed to do this.)

When the node gets initialised (or at least this is what I think is happening here), I left the ‘getting of the config node’, but change it from a const to a var.

    function mssql(config) {
        RED.nodes.createNode(this, config);
		var mssqlCN = RED.nodes.getNode(config.mssqlCN);  //this is the original configuration, might need to change to var
        const node = this;

When the node gets called at runtime (node.on), I get the incoming typed input value (i.e. Plant1), and lookup its id from all loaded nodes (i.e. ‘28f23f6e8d6052e4’).
For this config-nosd it will have type = ‘MSSQL-CN’ and have a name of ‘Plant1’.
(I found that note all nodes might have names, others have ‘’nickname,; all have id’s though.)
I then get the new (dynamic) configuration node

        node.on('input', function (msg) {
				//this is the new connection that should be used that comes from msg	
				var mssqlCNdynamicLabel;
				var mssqlCNdynamicValue;
				mssqlCNdynamicLabel = RED.util.evaluateNodeProperty(config.mssqlCNdynamic, config.mssqlCNdynamicType, node, msg); //this should be enhanced for flow and global
				var mssqlCNdynamicValue;
				RED.nodes.eachNode(function(node) {
				   if (node.type === "MSSQL-CN" && node.name === mssqlCNdynamicLabel ) {
					  mssqlCNdynamicValue = node.id;
				   }
				});
				mssqlCN = RED.nodes.getNode(mssqlCNdynamicValue);	 //this now sets the new connection

This works but I will like:
• The dynamic connection and original config-node to be merged
• Being able to have types inputs as well as a ‘standard’ config node

Hi @GerritSmit
Welcome to this forum.

Sorry to jump just on the first sentence you posted: There is no "standard" configuration node.
The designer of a node creates the UI and defines the properties the node is going to support. And of course, a TypedInput field may be used in any property dialogue ... on the decision of the node designer.

If node-red-contrib-mssql-plus is missing a functionality, you could (in this order)

  • raise an issue in the repository of this node
  • create a pull-request for the node and contribute the missing functionality
  • fork the node and add the functionality to your (personal) implementation.

Hope this helps... at least a bit!

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