Is there a way to run a microflow on close of browser/tab?

0
Is there a way to run a microflow when the user closes the tab or their browser in Mendix 9? Previously I used the widget called “LeaveAction”, but I can no longer find that in the App Store.
asked
2 answers
11

Hi Sharon Steiner,

Kindly place the below js code in html snippet and enable javascript with jquery.

if wants this functionality across all the pages you have to place the snippet in the layout that is being used.

you can place the snippet top of the page, if you want for this in specific page.

window.onbeforeunload = function(e){
    var msg = 'Are you sure?';
    e = e || window.event;

    if(e)
        {

e.returnValue = msg;
}
mx.data.action({
    params: {
        actionname: "ModuleName.MicroflowName" 
    },
    origin: this.mxform,
    callback: function(obj) {
        // no MxObject expected
        alert("Just petted the cat a little");
    },
    error: function(error) {
        alert(error.message);
    },
    onValidation: function(validations) {
        alert("There were " + validation.length + " validation errors");
    }
});
    return msg;
}

 

Thanks.

answered
3

Hi Sharon Steiner,

There is a java action “ executeMicroflowInBackground” available in Community commons to execute microflow in background . So you can use it.

For more details refer:

https://docs.mendix.com/appstore/modules/community-commons-function-library/#36-execute-microflow

answered