Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

How to capture the name of the calling activity



How to capture the name of the activity, which calls a current activity, without passing that name as parameter?


Include the code given below in the Java step of the called activity. actName variable gives the calling activity name.
String javaClassname = "";
      StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace();
      int j=0;
      for(int i=0; i< stacktrace.length ; i++){
      javaClassname = stacktrace[i].getClassName();
      //oLog.infoForced("classname : "+stacktrace[i].getClassName() + " and method name : "+stacktrace[i].getMethodName() );
      //oLog.infoForced("javaClassName : "+javaClassname );
      int startIndex = javaClassname.indexOf("_action_")+8;
      //oLog.infoForced("index start : "+startIndex );
      int endIndex = javaClassname.lastIndexOf("_");
      //oLog.infoForced("index end: "+endIndex );
      String actName = javaClassname.substring(startIndex, endIndex );
      //oLog.infoForced("act name = "+actName);

Published November 22, 2016 - Updated October 8, 2020

Was this useful?

60% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us