I have been working extensively in Node Red, creating a mechanism to load ERP data (mainly production order information) into Tulip. I am working with an ERP system named Level7, built on Business Dynamics specifically for the remanufacturing industry. I am working toward a three part strategy:
- Load data from ERP system in whatever form is available. In my case, it’s actually three separate tables: Production Orders, which have multiple Items, which have multiple production Routes.
- Transform into a common representation, a stream of objects each containing a complete production order (including all its items and all of each item’s routes)
- Send to Tulip, which means loading the table rows then creating the links.
The idea of step 2 is to transform ERP data into a common format so that the by the time you get to step 3 you’re agnostic to the actual ERP system. The idea is to make it adaptable. Ideally this common representation would comply with some well known standard like ISA95 / B2MML. I’m on a deadline, so I am not starting there, but it’s where I hope to get.
In Tulip, adding links is a separate step from creating the records. I have proposed Tulip add the ability to send links with the create table request, but for now links have to be sent in as a separate API call.
Sometimes in node red it’s hard to control flow execution. Time delays are not a safe way to control when things happen. There are some built-in ways in node red to wait for multiple nodes to complete, but using them correctly is difficult if you care about edge cases and exceptions (and you should). The right way way to control a sequence of node executions is through the flow.
To accomplish this, I created a flow like this:
double click to zoom in
Remember, what I am trying to do here is add links after a Create Record. The way this flow works is that each time it writes a row, if that row contains a links array the link request is formatted into an HTTP request then called using the standard Node Red HTTP Request node.
For this to work I had to modify the node-red tulip library slightly. I created an option in the table request that causes it to pass the initial request through to its output. Here is an example of the new output of the Tulip Table node, with the new “Request in Response” option turned on:
This option is off by default, mostly to avoid causing any backward compatibility issues*. The result is that at the output of the tulip table write I now see this:
Note that links array. Presently, Tulip Table node doesn’t know what to do with this, but that’s okay (for now) - the key element here is that it passes it through the Table node unperturbed, so that a subsequent node can see it.
In my flows, after the table node I have a second function block that formats the elements of my links array into a series of outputs emitted one per link. These outputs form the request definitions for a standard HTTP request node. This is not a great long term solution, mainly because I have to duplicate the authentication process rather than use the Tulip configuration node. It makes the whole thing less portable. My hope is to eventually just add a Tulip “links” node (similar to the tables node), but before I do that I want to have a discussion with Tulip so I don’t duplicate their own internal efforts.
To support all of this, I have issued a pull request to the tulip node-red official library: I realize Tulip is very busy, if they can’t get to this I may fork and re-publish the library (I’d prefer to avoid such splintering if possible, but this is actually rather urgent to me. If I do fork it, the entire thing will definitely be rewritten in typescript).
I’m really interested in hearing from other members of the community, especially ones who are using Node Red for doing this type of integration. Any thoughts/questions/wishes? Do you work with linked tables?
*I said that that the option is turned off for backward compatibility at the request of someone from Tulip. I don’t really agree with this … all I’m doing is adding a new attribute to the output msg, any properly written existing code should ignore attributes it doesn’t understand without it generating an error. But I’ll yield to Tulip here, it’s their library.