Microflow not receiving multiple parameters from JS

0
When I try to call a Microflow using the mx.data.action API call with 2 guids, my microflow says that both of the objects it receives are empty. This happens regardless of the order I supply them in. See below. // Assume that 12345678901234567 is of the first parameter and 23456789012345678 is the 2nd parameter in the Microflow. mx.data.action({ params: { applyto: "selection", actionname: "MyFirstModule.DS_Test_Multiple_Objects", guids: ["12345678901234567", "23456789012345678"] }, callback: function(obj) { console.log(obj); }, error: function(error) { alert(error.message); } }); Found field from view: <empty> and cell <empty>. Exists? no However, when I only supply 1 guid, the Microflow receives this single object. Setting the first parameter only: mx.data.action({ params: { applyto: "selection", actionname: "MyFirstModule.DS_Test_Multiple_Objects", guids: ["12345678901234567"] }, callback: function(obj) { // expect single MxObject console.log(obj); }, error: function(error) { alert(error.message); } }); Found field from view: set. and cell <empty>. Exists? no Setting the second parameter only: mx.data.action({ params: { applyto: "selection", actionname: "MyFirstModule.DS_Test_Multiple_Objects", guids: ["23456789012345678"] }, callback: function(obj) { // expect single MxObject console.log(obj); }, error: function(error) { alert(error.message); } }); Found field from view: <empty> and cell set.. Exists? no Why is that, and how can I fix it? I’m following the example from https://apidocs.mendix.com/7/client/mx.data.html with multiple guids. The two objects I’m passing are of different types.   Thank you in advance.
asked
2 answers
4

Hi Andreas, 

as far as I know, it is not possible to pass two or more objects to a microflow via the JavaScript API which are of different types. You can only pass multiple GUIDs of the same type, which results in a list of objects (same type) as the parameter. 

You could use something like a wrapper object, which is associated to the two objects you want to pass as parameters and in the microflow you retrieve them via those associations. 

answered
3

After a little further research, it appears that using mx.onlineData.executeMicroflow allows for calling microflows with multiple objects of different types.

The mx.onlineData API namespace doesn't appear to be documented yet, so this is taken from a trial-and-error approach.

mx.onlineData.executeMicroflow("MyFirstModule.DS_Test_Multiple_Objects", {
  "FirstParameter":{
    "guid":"12345678901234567"
  },
  "SecondParameter":{
    "guid":"23456789012345678"
  }
}).then(console.log);

 

answered