How is your experience with the OutSystems Community?
24
Views
3
Comments
Override OutSystems Confirmation Message with Swal.Fire
Question
Application Type
Reactive

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?


confirmation.jpg
2026-05-21 04-48-12
Deepa Tiwari

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

2023-12-26 10-35-28
OutSystems Neo
Staff
AI Generated

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.

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.

Why your approach doesn’t work

window.confirm = async function (message) {
    const result = await Swal.fire(...);
    return result.isConfirmed;
};
  • async function returns a Promise, not a boolean.
  • When OutSystems (or browser code) does something like:
    if (confirm("Are you sure?")) {
        // delete/update
    }
    
    it expects confirm() to immediately return true/false. Instead, with your override, it gets a Promise, so the condition is not evaluated as intended.

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:

  1. Remove the built‑in ConfirmationMessage from the widget (or don’t use it).
  2. In the widget’s OnClick / swipe action:
    • Add a JS node that calls SweetAlert and sets an Output Boolean (e.g. IsConfirmed) based on the result.
    • After the JS node, use an If node to decide whether to proceed with the delete/update.

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;
});
  • IsConfirmed is an Output parameter of the JS node.
  • After the JS node, an If node with condition IsConfirmed executes the delete/update only when true. This pattern is the same one described in the confirmation‑list example using confirm() but replacing it with SweetAlert. Confirmation message reactive list action

If you still want a global abstraction

You can create a client action like ConfirmWithSwal that:

  • Has an Input Message and an Output IsConfirmed.
  • Internally has one JS node with the SweetAlert call above.
  • Everywhere you currently rely on ConfirmationMessage or confirm(), call ConfirmWithSwal instead and branch based on IsConfirmed.

This gives you a reusable, “central” confirmation behavior without relying on overriding the browser’s native confirm().

Summary

  • Overriding window.confirm with an async function will not correctly replace OutSystems’ default confirmation, because the platform expects synchronous behavior.
  • Use a client action with a JS node (SweetAlert) and an output boolean, then control your logic with an If node.
  • Don’t rely on OutSystems’s ConfirmationMessage property if you want custom SweetAlert; replace the pattern with your own confirmation action.
This answer was AI-generated. Please read it carefully and use the forums for clarifications
2023-09-21 12-55-43
SIRAJKHILJI

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

Message

Title

ConfirmText

CancelText


Events

OnConfirm

OnCancel


Then every OutSystems button can use the same component.

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