I want to override the default confirm JavaScript function, for that I have created a script and added the following function, Application is showing the Swal confirmation, but default confirmation is not overriding the behaviour.
(function () {
const originalConfirm = window.confirm;
window.confirm = async function (message) {
const result = await Swal.fire({
title: 'Confirmation',
text: message,
icon: 'question',
showCancelButton: true,
confirmButtonText: 'Yes',
cancelButtonText: 'No',
allowOutsideClick: false
});
return result.isConfirmed;
};
window.originalConfirm = originalConfirm;
})();
can you let me know, how to override the OutSystems default confirmation?
your Swal code is working, but it is overriding window.confirm(), not necessarily the OutSystems Confirmation Message mechanism. For a reliable OutSystems solution, use a custom confirmation Client Action/Block and handle the Yes/No result explicitly. Or Use this - SweetAlert
You can’t fully “override” OutSystems’ built‑in confirmation behavior by redefining window.confirm, because the platform doesn’t always use confirm() directly, and when it does, it expects a synchronous boolean return value.
window.confirm
confirm()
Your override is async (returns a Promise), while confirm() is a blocking, synchronous function. OutSystems’ generated JS (and the browser) will still treat confirm() as synchronous, so the behavior won’t match what the runtime expects.
window.confirm = async function (message) { const result = await Swal.fire(...); return result.isConfirmed; };
async function
if (confirm("Are you sure?")) { // delete/update }
true/false
Promise
Also, OutSystems’ built‑in ConfirmationMessage on links/buttons is not just a raw call to window.confirm; it is injected by the platform and may be handled by its own JS, so patching window.confirm doesn’t necessarily intercept all of those calls. Extend Your Mobile App Using JavaScript
Instead of trying to override the platform’s default confirmation, implement confirmation explicitly where you need it:
ConfirmationMessage
IsConfirmed
Example JS node (Reactive):
Swal.fire({ title: 'Confirmation', text: $parameters.Message, icon: 'question', showCancelButton: true, confirmButtonText: 'Yes', cancelButtonText: 'No', allowOutsideClick: false }).then(function(result) { $parameters.IsConfirmed = result.isConfirmed; });
true
You can create a client action like ConfirmWithSwal that:
ConfirmWithSwal
Message
This gives you a reusable, “central” confirmation behavior without relying on overriding the browser’s native confirm().
There are components specifically designed around overriding native window.confirm; for example,
the current OutSystems Forge has a Confirm component whose stated purpose is to override the native window.confirm.
https://www.outsystems.com/forge/component-overview/22414/confirm-o11
But if your requirement is specifically SweetAlert2, I would recommend not overriding window.confirm globally.
Instead, create a reusable:
ConfirmationModal Web Block with:
Inputs
Title
ConfirmText
CancelText
Events
OnConfirm
OnCancel
Then every OutSystems button can use the same component.