Get the current action name.

By Marco Arede on 2 Sep

Problem: I need to implement a solution, where a high number of screen and user actions assign their name into a variable.

As is: At this moment, we can only do it hard coded, writing the action name manually.

To be: It would be great if we could do it dynamically. For example, having a built-in-function, with a behavior similar to a "".

J.3 Sep

you can do it with an extension

this c#-snippet will get you what you want:

// // </summary>
/// <param name="ssName">name of the calling action</param>
/// <param name="ssParentName">name of the parent</param>
/// <param name="ssSuperParentName">name of the parent of the parent</param>
public void MssGetActionInfo(out string ssName, out string ssParentName, out string ssSuperParentName) {
    ssName = "";
    ssParentName = "";
    ssSuperParentName = "";
    //this should always work!
    StackTrace st = new StackTrace();
    if (st.FrameCount > 4)
        //0 and 1 are we.
        // 2 should be the action calling this action.
        // 3 is the parent
        // 4 parent of the parent.
        //so if you have this in a log-action, you will need parent and superparent.
        ssName = st.GetFrame(2).GetMethod().Name;
        ssParentName = st.GetFrame(3).GetMethod().Name;
        ssSuperParentName = st.GetFrame(4).GetMethod().Name;
} // MssGetActionInfo

J.27 Sep (4 weeks ago)

another way is (for .net)

but I cannot use this in an extension since it's getting overwritten everytime :/