How to get information on the current action that is being executed


#1

ActionContext.dump() will provide the ActionContext (c3ShowType(ActionContext)) of the current action that is being executed.

This is useful if you want to find out more about the context of an action while it is being executed on the server. It returns an ActionContext object that has fields such as typeName, action, userName that give insight into the exact action being executed.

c3CurrentAction() is another command that can be useful for finding out more about a given action.


#2

Thanks,
I don’t see c3CurrentAction().
How can I load it on my environments?


#3

Hello,
Let’s see if we can find it together. Would you mind sharing generally how you are trying to invoke it (static/console, in javascript, in python, etc.)?


#4

static/console javascript


#5

@ColumbusL c3CurrentAction() is probably a very recent addition? I don’t see it even on 7.8.4.

ActionContext.dump() is there but will probably work only if embedded within the action itself - you can’t use it to examine actions that are currently running on the cluster. Correct?


#6

I believe c3CurrentAction() was introduced in 7.7, but I am not certain. The first use of it that I encountered was ~6 months ago.

To @yaroslav’s point, ActionContext.dump() is essentially useful for seeing the user, their permissions, as well as the tenant and tag the user is operating within. From what I have seen the Type and Action of the context will always be ActionContext:dump.

However, I have found that c3CurrentAction() is able to be embedded in a javascript method defined on a type, and return details on the action that is underway.

Here’s an example of how this can be used to evaluate the type associated with the current action. This exact example is useful if you are defining a flexible method on an abstract type that will be mixed in by multiple persistable types.

// <<<in some TypeName.js file>>>

function someFunction(){
var type = c3Type(c3CurrentAction().getTarget().getType());
}

#7

c3CurrentAction() works well INSIDE the implementation of a typesytem method but is not available from the console.