Sc_confirm is executed even when it shouldn't - bug?

As a test, I have this code on a PHP button on a grid app:

if (1==2)
{
sc_confirm(“First”);
}
else
{
echo “Second”;
}

When executed, the confirmation dialog is displayed but it never should because 1==2 is always false.

After pressing the OK button in the confirmation dialog, the text “Second” is displayed in the app and this is correct.

I tried other tests and it seems that when sc_confirm is anywhere in the code, it will always be executed regardless of the conditions.

Is this the expected behavior? Or is it a bug?

SC_CONFIRM is only set up to work in forms or control apps (on click). When I tried this in a blank app it works as expected and only echos ‘second.’ In a control app I set up a text field as an ‘on click’ which really makes little sense. It worked as expected. I set up a php button in the control app and the grid and it worked as you stated. So in a grid you are out of luck and I’m not sure in a control what the conditions would be for an ‘on click!’ Maybe you can have the button take you to a blank that executes the confirm and then redirects to whatever. Seems VERY convoluted.

This is still not working within a php button. Is there a better choice for a yes/no confirmation?