Warning at end of script to bring to front

I have a script that is saved as a application. I need it to pop up a warning as it finishes running.

-- Then show the dialog with warning icon
display dialog "Please check the sender email before sending." buttons {"OK"} default button "OK" with icon caution

I tried this and it works, but I need it to come to the front of everything, presently it hides under other stuff.

How to fix?

Put the command activate before the display dialog

OK thanks. would that mean that until I hit the OK button the warning stays on top and after that Outlook shows?

No. It only means the dialog will initially be frontmost. You can still click on other open apps to bring them frontmost while the dialog is open.

Thanks, always learning stuff.

You never stated if you wanted the warning dialog to stay atop.

There is a conversation about a System Modal Dialog here.

Nonetheless, like @robertfern said, I’d recommend against using one; just activate first so the dialog comes front-most.

Thanks proebuck helpful.