get parameter from action calling

1
Hi there! I'm new in mendix, so don't judge too hard. what I need: - from client side call microflow that will will return list of objects with selection parameters what I do: - created microflow with parameter - parameterName - calling action from client in such way mx.data.action({ params: { applyto: "set", actionname: "MyFirstModule.MicroflowName", xpath: "//MyFirstModule.EnetityName", constraints: '[parameterName="parameterValue"]', sort: [["parameterName", "asc"]], }, origin: this.mxform, callback: function(obj) { console.log('got list', obj); }, error: function(error) { console.log('got error', error); } }); - in microflow created parameter with parameterName and type string and passing it to Action with type Retrieve Objects ['parameterName' = $parameterName] - also tried before Retrieve Objects Create Variable, where will store parameterName My problem: - parameter that I'm trying to retrieve is empty My question: - where I'm wrong
asked
2 answers
0

As far as I know, you cannot pass primitive parameters to a microflow via mx.data.action. You have to pass it Mendix objects. Since I don't know what functional problem you're trying to solve here, I'll give a few suggestions:

  1. Forget the use of a microflow and use mx.data.retrieve with an XPath contstraint to get the list of objects you want
  2. Use the microflow, but pass it a Mendix object instead.
    1. If you have a mendix object handy with the data you need in the microflow: set 'applyto' to 'selection' and 'guids' to:  [yourObject.getGuid()]
    2. If you don't: add a simple non-persistable entity to your domain model with a string attribute, then use mx.data.create and the "set" function on that object to create and set up your Mendix object. Then pass it to the microflow as above.

 

EDIT: I don't think you need custom JavaScript to achieve what you're trying to do. Instead:

  1. Create a simple non-persistable entity to your domain model with a string attribute, call it something like 'Search'
  2. Create a microflow that creates and returns an object of the type 'Search'
  3. On your page, add a data view that gets its data from that new microflow you just created
  4. Add an input for the string attribute of that entity (if not automatically created)
  5. Add a button that runs a microflow, and set the button label to "Search"
  6. The button should run a microflow that has a "change object" activity in it that operates on the 'Search' object. Be sure to set "refresh in client" to yes.
  7. Inside that data view, add a data grid that gets data from a microflow. This microflow will be able to take the 'Search' object as a parameter, and should return a list of objects which will display in the grid

 

This should create a working input box that you can use to affect the contents of your grid.

answered
0

I think that the Constraints is applied to the Xpath not to the Retrieve action  in your microflow.

answered