# Using node-red with ERP using ActiveX COM

**URL:** <https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987>\
**Category:** Industrial\
**Tags:** function-node\
**Created:** [8 April 2022 15:17 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987 "2022-04-08T15:17:49Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![steveneyre](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@steveneyre](https://discourse.nodered.org/u/steveneyre)\
**Post date:** [8 April 2022 15:17 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/1 "2022-04-08T15:17:49Z")

</div>

Has anyone had any success using node-red to consume activeX COM objects? My specific requirement is to communicate with an ERP system (3rd party software) installed on the same machine node-red is installed so I can transact with it

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [8 April 2022 15:48 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/2 "2022-04-08T15:48:31Z")

</div>

I've not tried but maybe you could share some more about what you are trying to achieve so we could give some thoughts that might help?

Is this a user interaction? Automation?

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [9 April 2022 13:08 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/3 "2022-04-09T13:08:49Z")

</div>

If not possible directly, you could eventually do it in Python. I did this once in Python myself several years ago. Today I would then also use MQTT to communicate with NR

ERP \<---\> Python/MQTT Client \<---\> MQTT Broker \<----\> NR w MQTT Client

---

<div class="post-metadata">

**Author:** ![steveneyre](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@steveneyre](https://discourse.nodered.org/u/steveneyre)\
**Post date:** [12 April 2022 08:02 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/4 "2022-04-12T08:02:54Z")

</div>

Thank you. So, we have a third party manufacturing requirements planning (MRP) system that sits on a SQL Server database. I have successfully accessed the data using [**node-red-contrib-mssql-plus**] which is great for reading data.

The challenge I have is writing to the database because there is a business layer that encapsulates a variety of undocumented business rules, so, by writing straight to the database we will corrupt it. So a simple request like [Create Purchase Order] might actually affect 3 or 4 database tables.

The business rules are implemented through a **class library in a COM component (DLL)** installed on the same server as Node-RED. I can browse the interfaces using something like Visual Studio but I can't see a way to access the DLL/COM interfaces using Node-RED so I can invoke these end-points.

There is currently no API onto the MRP and the risk/cost of replacing it would be prohibitive at this stage. We are currently using a proprietary third party platform to achieve the above requirement, it's expensive but more importantly difficult to maintain the equivalent flows which is why we are investigating Node-RED.

Appreciate any input/guidance you can provide on this.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 April 2022 08:09 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/5 "2022-04-12T08:09:53Z")

</div>

I have, in the past, had to do something similar. What I did was to watch the database (using profiler) and understand what changes were made then simply re-created that in node-red - bypassing the DLL altogether.

Failing that, you could create a wrapper (proxy) application in VS (`c#` or `VB.NET`) that includes an MQTT client lib (there are a few to chose from). Have this wrapper application subscribe to a set of known topics that then call the various Active-x functions (e.g. a proxy application) & then publish the results back to a known topic for node-red to consume.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [12 April 2022 08:50 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/6 "2022-04-12T08:50:06Z")

</div>

Exactly, but I did it all in Python 😉 Importing a DLL and to use functions via entry points is straight forward

```auto
from ctypes import .....

```

Anyway would work the same, just the individual taste for language selection and suitable prefered tools that matters.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 April 2022 08:51 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/7 "2022-04-12T08:51:10Z")

</div>

Is python able to automate COM (AKA Active-X) DLLs?

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [12 April 2022 08:53 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/8 "2022-04-12T08:53:19Z")

</div>

yes, I have done it but the result was then running under Windows

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [12 April 2022 09:04 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/10 "2022-04-12T09:04:27Z")

</div>

In that case, loading an ActiveX (OCX), I just code as below (simplified), just gives the idea

```auto
import win32com.client

```

and then

```auto
    def attachOCX(self, flag):
        #Attach interface to the OCX
        self.AxkmkusbT = None
        try:
            self.AxkmkusbT = win32com.client.Dispatch(
                "KMKUSB5I8OOCX.KMKUSB"
            )
        except: 
            raise eg.Exception(
                self.b_nbr,
                self.text.txt_OCX_CannotBeFound_T
            )
        if self.AxkmkusbT != None and flag:
            print self.b_nbr, self.text.txt_OCX_Found_T

```

---

<div class="post-metadata">

**Author:** ![steveneyre](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@steveneyre](https://discourse.nodered.org/u/steveneyre)\
**Post date:** [12 April 2022 09:05 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/11 "2022-04-12T09:05:55Z")

</div>

That is really useful thank you all!  
I'll give that a try.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 April 2022 09:12 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/12 "2022-04-12T09:12:16Z")

</div>

I prefer python but for automating Active-x in a `.NET` env is far easier.

Include a reference to the DLL, declare an instance `Dim WithEvents AxThirdParty1 As AxThirdParty.ThirdPartyControl` then call its functions `AxThirdParty1.DoSomething()`

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [12 April 2022 10:26 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/13 "2022-04-12T10:26:42Z")

</div>

Quite a few references to calling COM DLL's from node.js

[https://www.google.com/search?q=node.js+how+to+call+a+COM+dll](https://www.google.com/search?q=node.js+how+to+call+a+COM+dll)

Though I imagine they all assume that node.js (in your case Node-RED) will be running on Windows.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 April 2022 10:31 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/14 "2022-04-12T10:31:25Z")

</div>

Indeed, there is this: [win32ole - npm](https://www.npmjs.com/package/win32ole)

It is 9y old - but might work (or there may be newer alternatives)?

Update: there are quite a few 🤔 This one was published 3m ago: [winax - npm](https://www.npmjs.com/package/winax)

---

<div class="post-metadata">

**Author:** ![paulkeates](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@paulkeates](https://discourse.nodered.org/u/paulkeates)\
**Post date:** [12 April 2022 13:51 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/15 "2022-04-12T13:51:25Z")

</div>

Hi,

If you are able to 'connect' and 'drive' the COM objects with Python then you would not need to use MQTT or any alternative broker. Python and interface with Node-RED. There may be advantages of using MQTT if you wish to take a pub / sub 'messages' type approach, but it is not strictly necessary.

Cheers,

Paul

Paul

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [12 April 2022 14:12 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/16 "2022-04-12T14:12:55Z")

</div>

> [@Steve-Mcl](#):
>
> This one was published 3m ago: [winax - npm](https://www.npmjs.com/package/winax)

With this I assume you could maybe even use it inside NR in a function node!?? Just installing & adding a line in settings.js...

```auto
    functionGlobalContext: {
        winax:require('winax'),

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 April 2022 14:21 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/17 "2022-04-12T14:21:16Z")

</div>

Dont need to do that if you dont want to...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3ea168fb9a160632d161de72004405a13d7cba48.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/9/79ea2037afd22d0620becd1854f2233728f67a6c.png)

### note

your node-red server must have the developer tools installed for these nodes as they have a built step

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 June 2022 14:22 UTC](https://discourse.nodered.org/t/using-node-red-with-erp-using-activex-com/60987/18 "2022-06-11T14:22:10Z")

</div>

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