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
3 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
0

Hi Ivo Sturm,

I am trying to implement the solution that you have provided but it is not working . What exactly I need to do is I want to pass two parameters (unit and Parameter) values to microflow(Show_ProductionGraphData).These values I am passing directly from widget It is not coming from any entity.So could you please guide me on this how can I pass these values to microflow without using GUIDS and what object do I need to pass inside the callback function.I do not want to use any dojo library.

params: {

             applyto: "selection",

              actionname: "MyFirstModule.Show_ProductionGraphData",

               guids: [ "281530811285515"],

               unit: vUnit,

               parameter:  vParameter

              origin: this.mxform,

              callback: function() {

                alert(vUnit,vParameter);            

             // var parameters = vUnit;

               

                 //return temp;

             },

          error: function(error) {

            

        //      alert(error.message);

                 console.error(error);

            }

 

answered
0

I have the same issue and I cannot find a solution. Can anyone help by providing a working example?

answered