can i show alert when i finish running the function?

can i show alert when i finish running the function?

how i can show alert inside the custom function or popup notification.
when i use alert inside the custom function it show this error

Error at line number:  2
'ALERT' task can be used only in on load, on validate and on change actions