Q:

Flow in VF page - set return url to id of Flow variable

I have a simple Visual Flow embedded in a simple Visualforce page that creates a record in a custom object.  When the flow ends, I would like to redirect to the detail page of the record that was just created (using a Flow variable).  How can I reference a flow variable in the 's returnurl parameter?

A:

Don't include quotes around the variable name: this causes it to be interpreted as a literal string. Instead, you have to get the value from the flow itself, which means you need a controller. In your extension, add the following code:
public Flow.Interview.NewAbsence flowInterview { get; set; }
public Id getNewAbsenceId() {
    return flowInterview.newAbsenceId;
}

Now, modify your flow to set the flowInterview attribute:
<flow:interview name="NewAbsence" interview="{!flowInterview}" finishLocation="{!NewAbsenceId}" buttonLocation="top" />

Now, when your flow finishes, it will redirect to the Id provided in the variable. You need to make sure your flow variable is set to either "Output" or "Input and Output", or it won't work.
Edit: See this documenation for more details.

