Retrieve Microflow Name

0
How to retrieve microflow name in java action class. I am writing a JMS connector. connector has a configuration domain object, that has combination of  microflow name, action as compound key. I want to retrieve last microflow name and pull the configuration object.  I am using below code to retrieve microflow name,    Stack<CoreAction<?>> actionStack = this.getContext().getActionStack();         CoreAction lastAction =  actionStack.peek();   but it returns 'action-174'. 
asked
1 answers
3

Check https://forum.mendix.com/link/questions/90433

 

Created from answers on the forum (use search):

create java action with a param level to get the calling mf or current mf

// BEGIN USER CODE
		int intLevel = level != null ? level.intValue() : 1;
		IContext context = this.getContext();
		Stack<CoreAction<?>> coreAction;
		CoreAction<?> nthCoreAction;
		String microflowName = "";
		if (context!=null){
			Core.getLogger(this.toString()).trace("Context exists");
			coreAction = context.getActionStack();

			if (coreAction!=null){
				int actionStackSize = coreAction.size();
				Core.getLogger(this.toString()).trace("coreAction exists with size: " + actionStackSize);
				// determine the level to get the stackaction from. The actionStack contains all levels of microflows currently active, so also all sublevels. 
				int Level = (actionStackSize - intLevel) - 1;
				// make sure the ArrayIndexOutOfBounds exception can't occur
				if ((Level >= 0) && (Level < actionStackSize)){
					Core.getLogger(this.toString()).trace("get on " + Level + " nth element");
					nthCoreAction = coreAction.get(Level);
					if (nthCoreAction!=null){
						Core.getLogger(this.toString()).trace("nthCoreAction exists with name " + nthCoreAction.getMetaInfo().toString());
						microflowName = nthCoreAction.getActionName();
					}
				}
			}
		}
	
		return microflowName;
		// END USER CODE

😎

answered