How to save input data in database om closing browser
Application Type
Reactive

Hi Team,

I want to auto-save input data in database on closing browser

Hey Pallavi,

You'll probably need to use JavaScript to detect that the browser is closing and call an action there, using the $actions predefined object.

Here's a forum thread that may help you: https://www.outsystems.com/forums/discussion/71304/invoke-a-client-action-when-browser-tab-closes/

Here's a step-by-step tutorial on how to do it: https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/JavaScript/Extend_Your_Mobile_and_Reactive_Apps_Using_JavaScript

Cheers

Add  below code on your url open button and try this 

var win =  window.open($parameters.RedirectionLink,"_blank");

var timer = setInterval(function(){if(win.closed){  

    clearInterval(timer);  

    setTimeout(function CallYourFunction() {

        $actions.CloseAndSaveData() // this is the client action 

    }, 2000);

}},500);

Hi Pallavi,

Add below JavaScript on onReady event of you screen.

window.addEventListener("beforeunload", function(event){

$action.Saveinputdata();

});

you can write save data logic in "Saveinputdata" action.


Hope this helps.

Shoeb

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.