How to call a microflow with parameters from a JavaScript action

0
I want to add logs at different points inside my JavaScrip action. But these logs need to be shown in the Mendix (server) logs. Unless there's a better way to do it, I was thinking of calling a microflow (that is run server side) from the JS action using Mendix Client API call, that creates the logs for me. It takes 3 parameters: the log message (string), the LogNode (string) and the LogLevel (enum from logging module).   But I cannot find clear documentation how to call a microflow with string/enum parameters from JS. I can only find how to pass a (list of) object(s) to the give MF, but not other types of parameters.    Anyone an idea?  If there is a better way to send logging to the Mendix server-side logs from a JS action, then I am open to suggestions. :)   This is the microflow (called MyModule.LogMessage).
asked
1 answers
0

Hi Joël,

 

 

Calls to `console.log()`, `console.warn()`, and `console.error()` are intercepted by the Mendix Client and forwarded to the runtime. You can view these logs in the Studio Pro console. You may need to change the loglevel of the `Client` log node to see the logs you wish to see.

 

Javascript action containing logging calls to log, warn, and error

The Studio Pro Console showing the three logging calls from the JavaScript action.

 

As for calling microflows from Javascript actions, it seems you can define a parameter on the Javascript action that accepts a Nanoflow. But I don't see any documentation suggesting you can do the same for microflows.

 

Let me know if this helps,

Arjo

 

Edit:

You can pass parameters to a nanoflow, and then call a microflow from the nanoflow. In the examples below I created a nanoflow that logs the given message and loglevel and calls a microflow that does the same. You can see in the screenshot of the Studio Pro console that all three methods end up being collected by the runtime.

Javascript action calling console.log but also a specific nanoflow with a message and loglevel

The microflow that logs a given message at a given loglevel. It also passes its given parameters to a microflowThe Studio Pro console showing that all three logging methods are collected.

answered