Microflow with parameter invoked from custom widget

5
Application: simple map, on click on some region is user forwarded to form containing statistics. Problem is that Im unable to propagate information about what user clicked to the other form. Realisation is that my simple custom widget invokes execution of microflow which opens new form instead of current one (using mx.processor.xasAction). Microflow has attribute of type String and contains just two operations "Retreive object from database" and "Show form List in content", which works fine when not called from widget. As far as I understand it, I should declare attribute of microflow somehow in xml declaration of widget parameters and then probably pass it as one of parameters of mx.processor.xasAction (or linking between parameter and microflow is done automatically thanks to xml?) Update 1: Hello again, unfortunately Im still unable to make mendix work as expected, so I will try to explain in more detail: <?xml version="1.0" encoding="utf-8"?> <widget id="custommodule.RegionMapWidget.RegionMapWidget" needsEntityContext="false" xmlns="http://www.mendix.com/widget/1.0/"> <name>Region Map</name> <description>Lets user select region from map.</description> <properties> <property key="regionToPreload" type="string"> <caption>Slave region to preload</caption> <category>Common</category> <description>Name of detailed region which should be preloaded, actually only one is "London" and any other value doesnt make sense.</description> </property> <property key="onRegionSelectFlow" type="microflow" entityProperty="regionDataSource"> <caption>Region onClick flow</caption> <category>Common</category> <description>Flow invoked onclick on region.</description> <returnType type="Void" /> </property> <property key="regionDataSource" type="entity"> <caption>Region datasource</caption> <category>Common</category> <description>Optional region to show.</description> </property> </properties> </widget> Please note: property key="onRegionSelectFlow" type="microflow" entityProperty="regionDataSource" , which is set to Region table. All the arguments defined in xml are also defined in inputargs and I can work freely with them. Then here goes the issue (following code is my best guess how to pass something as parameter (microflow expects input parameter regionDataSource), argument not passed): _execmicroflow : function(name, guids) { mx.processor.xasAction({ error : function() { logger.error(this.id + "error: XAS error executing microflow"); }, actionname : this.onRegionSelectFlow, regionDataSource: this.regionToShow }); where this.regionToShow contains 1 entity of Region according to following (cycle throught just to be sure theres a one record, which I have confirmed) this.regionToShow = mx.processor.getObjectsByXPath("//" + this.regionDataSource + "[Name='Thames Valley']", {}, dojo.hitch(this, this.setRegionToShow)); setRegionToShow : function(objArray) { for(var i = 0; i < objArray.length; i++) { this.regionToShow = objArray[i]; } }, Microflow is still the same, Ive just renamed input parameter to "regionDataSource", and it is an Object of type Region. Otherwise it contains only one activity "Client->Show form" pointing to form containing Data view with included data grid (opening of form works, data just arent filtered). Modeler isnt complaining about anything. Im using 2.5-beta. Thank you for all answers Update 2: Issue solved, so thank you very much everyone. Just a aditional thing which really helped me today - Create testing microflow and use it to try that target form really receives the data (retreive single object in microflow), and dont remove it until work is done!, otherwise you can end as me hunting ghosts but with "Apply context" on data grid accidentaly set to "false", especially when working in team. Knowing it sooner could save a day of my life :D
asked
4 answers
3

Hi Jan,

parameters are not passed in by name, but as an array with GUIDs. So your code should be:

_execmicroflow : function(name, guids) {
  mx.processor.xasAction({
        error       : function() {
            logger.error(this.id + "error: XAS error executing microflow");
        },
        actionname  : this.onRegionSelectFlow,
        applyto: 'selection',
        guids: [this.regionToShow.getGUID()]
});

}

answered
3

Currently, only Mendix Objects can be passed to a microflow from a client widget. In the xml, you can use the entityProperty attribute for this. (see for example the toplist widget).

More details can be found on https://world.mendix.com/display/Howto/Calling+a+microflow

answered
2

Instead of retrieving the object in the microflow you could retrieve it in your custom widget and send it with your microflow. This has the disadvantage that each region with a different object will require a different microflow.

answered
1

Hi all,

I am trying to create something similar. I have a working widget where users van select (one or multiple) regions on maps. I am trying to understand how other components can "subscribe" to my widget so they can use the selected regions for example for filtering datagrids or for other purposes.

My guess is that I want to trigger an event (change event?) which somehow holds the region-codes of the selected regions (array of strings). Or trigger a change event and expose some kind of method for other components to retrieve the selected regions?

Is this where microflows come into play or something?

I am not very familiar with the Mendix framework as you can tell by my question.

answered