Call a Nanoflow from Javascript action

0
Hi All, I am trying to call a nanoflow from javascript action, modeler version used is 8.6.2 I tried using this ,callNanoflow(params) mx.data.callNanoflow({ nanoflow: this.propertyWithNanoflow, origin: this.mxform, context: this.mxcontext, callback: function(result) { alert("Nanoflow completed with result " + result); }, error: function(error) { alert(error.message); } }); from https://apidocs.rnd.mendix.com/8/client/mx.data.html. without context and origin,  I get undefined error  Nanoflow call currently looks like this, mx.data.callNanoflow({ nanoflow: "Info.TestNanoflow", //not sure how to get and add context and origin here callback: function(result) { alert("Nanoflow completed with result " + result); }, error: function(error) { alert(error.message); } });                            I am not sure what the values of context and origin must be, i do not have ‘this’ available. Also how do I pass a parameter to this nanoflow call, I have an entity which i need to pass as a parameter to this nanoflow call   Thanks in advance,        
asked
2 answers
0

I'm afraid I've no complete answer for you, I struggle also with it.

The reason for the undefined message, is that the nanoflow should have been declared first.

You can however provide the nanoflow as a parameter to the JS-action.

Same applies for the context.

So you get something like this:

    return new Promise(function (resolve, reject) {
        mx.data.callNanoflow({
            nanoflow: testNanoflow, // parameter JS-action
            context: testEntity, // parameter JS-action
            origin: page, // ??????
            callback: function(result) {
                alert("Nanoflow completed with result " + result);
            },
            error: function(error) {
                alert(error.message);
            }
       });

Leaves the origin I guess, perhaps somebody else can provide some final answer here.

answered
0

Hi Divya,

Call I microflow could be really easy. with the Nanoflow parameter (not sure what version it was introduced)

https://docs.mendix.com/refguide/javascript-actions#2-2-2-type

Before it was a bit harder, to get the nanoflow exported, it required a helper widget

https://appstore.home.mendix.com/link/app/111132/

Alternatively, you could also return the date from the the JS action and call a sub nanoflow (now supported) with the data of your custom action.

Cheers, Andries

 

answered