pass two entity objects to a microflow with mx.data.action(..)

0
Hi, I’m working on this pluggable widget and I need to pass two objects to a microflow out of the widget. I have the following piece of code: mx.data.action({ params: { applyto: "selection", actionname: "MyFirstModule.ACT_Instance_OnClick", guids: ["8162774324609525", "7318349394477057"] }, error: console.error, }); Everything seems to work, no exception is thrown and the breakpoint in the microflow in the mendix studio pro hits.  The issue is that both of the parameters are empty. If I remove either one of the guids and only pass one of them I successfully obtain the object. I can’t seem to get it to work with two though.   The example from the documentation looks similar: mx.data.action({ params: { applyto: "selection" actionname: "MyFirstModule.GetFavoriteFood", guids: [ "281530811285515", "281530811285506"] }, ... }); I also found this question, but the answer doesn’t help.    Why doesn’t it work? What am I doing wrong?   Thanks for your help! - Tobias
asked
1 answers
3

Hi Tobias,

You can provide multiple object in a list (of the same entity inheritated entity). I you want to different entities… 

In dojo widgets you can not do it nicely. Though with a trick you can.

- Don’t use a microflow property in the XML but use a string, where the user enters the full MF name (module.mf_name) (please note, this can cause refactoring problems, is it will not auto update when the MF is renamed)

- mx.data.action, provide a selection and a context at the same time

var context = new MxContext()
context.setContext("MyFirstModule.Entity", "12345");

mx.data.action({
    params: {
        applyto: "selection"
        actionname: "MyFirstModule.GetFavoriteFood",
        guids: [ "281530811285515", "281530811285506"]
    },
    context: context,
    origin: this.mxform,
    callback: function(obj) {
        // expect single MxObject
        alert(obj.get("manufacturer"));
    },
    error: function(error) {
        alert(error.message);
    }
});

Would recommend doing it with pluggable widgets, as they support out of the box

Another work around, is that you set the relation from one object to another in the widget. and in you microflow retrieve over association

Cheers, Andries

answered