You can do it in a java action. There is already a forum thread discussing this. Let me find it
This is only possible with a java action. You need something like
getContext().getActionStack()[0].getName()
Check the documentation for more details https://apidocs.mendix.com/7/runtime/
-Andrej
Here is the old thread:
https://forum.mendix.com/link/questions/90433