Passing page parameter with Client API using mx.data.action

0
Hello, I have an HTML Snippet which runs JavaScript code that calls a microflow using the Client API. Reading the documentation, I can see that I can include xpath which will pass objects to the microflow as a parameter. However, I only need to pass it the current page parameter as that is the only entity I need for the microflow. window.mx.data.action({ params: { applyto: "set", actionname: "General.Test", xpath: "//General.DeleteMeTest", sort: [["Test","asc"]] }, origin: this.form, context: this.mxcontext, callback: function(obj) { alert(obj); }, error: function(error) { }, onValidation: function(validations) { } }); The code above passes ALL entities of type DeleteMeTest from the database to the microflow. However, the snippet is inside a data view which has the specific entity I need to pass to the microflow. Is there any way that can be achieved?
asked
1 answers
0

So you need the context entity. Then I think it is better to use another widget, JavaScript widget (with Context) for this.

With this widget you can get the Mendix object of the DataView and use this as a variable within the JavaScript code in the widget. Get the guid of it and then use in a Client API call like below. If you only have one guid, still add it to the array, as an input parameter to the below API call:

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

 

answered