Skip to content
Arthur edited this page Dec 8, 2023 · 5 revisions

LC0021 - Confirm() must be implemented through the Confirm Management codeunit from the System Application.

There are multiple benefits for implementing a Confirm() through the Confirm Management codeunit;

  • Automatical validation for IsGuiAllowed()
  • Help the user with setting a default response button (true/false)

Source: https://github.com/microsoft/BCApps/tree/main/src/System%20Application/App/Confirm%20Management

Example

Calling the Confirm() function directly

if Confirm(AreYouSureQst) then
    DoSomething();

Calling the Confirm() function through the Confirm Management codeunit

var
    ConfirmManagement: Codeunit "Confirm Management";
    DefaultAnswer: boolean;

DefaultAnswer := false;
if ConfirmManagement.GetResponseOrDefault(AreYouSureQst, DefaultAnswer) then
    DoSomething();

More on the why

There's great content out there on this particular topic, some examples

Clone this wiki locally