3

I have some code in a form action class that needs to get the flowExecutionKey from the RequestContext. I can't seem to find any documentation on how to do this. My class looks something like this:

public class MyFormAction extends FormAction
{
    public Event doStuff(RequestContext context)
    {
        String flowExecutionKey = ...??
        ...
    }
}

I know I really shouldn't need to ever get the flowExecutionKey, but I'm dealing with some legacy code that requires it. This method is being called as an entry action for a view state. I tried context.getFlowExecutionContext().getKey() but it returns null. context.getFlowExecutionUrl() also returns null. Is there any way to do this?

UPDATE

I was playing around with this some more, and context.getFlowExecutionContext().getKey() does get the the flowExecutionKey when the method is called in the <on-render> instead of <on-entry>. It is also worth noting that it works during <on-entry> on a later view state. The view state it's not working on is the very first view state in my flow. Is there some reason I can't get the flowExecutionKey in <on-entry> on the first view state?

dnc253
  • 39,967
  • 41
  • 141
  • 157

1 Answers1

4

The <on-entry> callback is executing during the inital POST to the server. This will have a URL something like http://server/myflow. After that's complete, webflow will issue a redirect to http://server/myflow?execution=e1s1. It's during this call that <on-render> executes.

So, the reason you're not getting the key in the initial <on-render is that there isn't a key allocated yet. And the key that you're seeing in later <on-render>s is actually the key of the previous view.

Take a look at RequestContext.getFlowExecutionUrl() too - that will tell you the URL of the current request. That should shed a bit of light.

MCDS
  • 260
  • 1
  • 5