How can I call microflow or nanoflow with parameters from a React Widget

0
How can I call microflow or nanoflow with parameters from a React Widget? I can retrieve data from Mendix to React Widget. But How can I send data from React Widget to Mendix?   Regards, Armando
asked
3 answers
1

To call a microflow or nanoflow from a widget use the client API: https://apidocs.rnd.mendix.com/8/client/mx.data.html

Here is an example that passes an object to the microflow:

mx.data.action({
    params: {
        applyto: "selection",
        actionname: "MyFirstModule.GetFavoriteFood",
        guids: [ "281530811285515" ]
    },
    origin: this.mxform,
    callback: function() {
        console.log('done');
    },
    error: function(error) {
        console.error(error.message);
    }
});

Note that it is currently not possible to send more than one parameter (unless it is a list of the same entity) or to send primitives such as string, boolean. As a workaround set a string attribute on an object and use that instead of a primitive string variable.

Hope this helps!

PS: Sorry for the bad formatting, the code widget wont accept any new lines

answered
1

Declare a property of type “action” in your .xml

<property key="<key>" type="action" required="true">
   <caption></caption>
   <description></description>
</property>

Use this in your component like this:

if (this.props.<key>) {
    this.props.<key>.execute();
}

If the configured action has a parameter the widget will derive this from the entity context you placed the widget inside of.

 

answered
-2

Take a look at this manual https://docs.mendix.com/refguide/javascript-actions n how to call a nanoflow from a javascript. You can pass the nanoflow as a parameter. See section 2.2.2

For calling a microflow: you can call a microflow from a nanoflow. So it takes two steps, but then you are there.

answered