how to trigger a onclick event for a button on tab click?

1
I am trying to add the functionality of calling a microflow when the tab is on the button please suggest any relevent idea or answer if u have worked on it before.
asked
1 answers
0

Trigger a microflow when the tab is on the button? Ok, you’ll have a use case for that, so let’s go:

$(document).ready(function() {             //Wait for all dom-elements to be rendered
try{  
  let TriggerHappy=$('.triggerhappybutton')[0];  // find input-element of triggerhappybutton
  TriggerHappy.addEventListener("focus", function(){
    <Call your microflow from javascript>
  });
} catch (error) {}
});

And then there is the bit how to call a microflow from javascript. Use mx.data.action for that passing along your module.microflow:

mx.data.action({
    params: {
        actionname: "MyFirstModule.CalledMicroflowFromJS"
    },
    callback: function(obj) {
        // no MxObject expected
        alert("Just petted the cat a little");
    },
    error: function(error) {
        alert(error.message);
    }
});

For examples see https://apidocs.rnd.mendix.com/8/client/mx.data.html

answered