I have a custom object that has a Master-Detail relationship to the Opportunity object. I have an embedded VF page on the Opportunity that uses Javascript to check conditions on the Opportunity, and if met, opens another custom VF page. The 2nd VF page, is simply calling a flow and setting a flow finish location to a 3rd custom VF page. All works properly, however, when the finish location to the 3rd VF page occurs, it is not pulling in the ID of the newly created custom object that occurred in the flow. Can anyone help me figure out why? 1st and 2nd VF pages and the controller for the 2nd page are below:

1st VF Page (Embedded in Opp):

<apex:page standardController="Opportunity">
    <apex:includeScript value="/soap/ajax/34.0/connection.js" />
    <script type="text/javascript">
        var SFInitial = new Object();

        SFInitial.openWizard = function(){
                "{!Opportunity.StageName}" === "{!$Label.Eng_OppStage4}" &&
                "{!Opportunity.Includes__c}" !== "Yes" &&

            return this;

        SFInitial.updateOpportunity = function(){
            sforce.connection.sessionId = "{!GETSESSIONID()}";

            var oppToUpdate = new sforce.SObject("Opportunity");
            oppToUpdate.Id = "{!Opportunity.Id}";
            oppToUpdate.Stage_To_Contract__c = false;


            return this;




2nd VF Page (Calls Flow & sets Finish Location):

<apex:page standardController="Opportunity" tabStyle="Opportunity" extensions="VF_SFController" action="{!SF}">

    <flow:interview name="S_Form" interview="{!myFlow}" finishlocation="{!SFid}">


Controller for 2nd VF Page:

public class VF_SFController{

public List<S_Form__c> SF {get; set;}

    private final Opportunity opp;
    public VF_SFController(ApexPages.StandardController myController){
        SF = new List<S_Form__c>();

    public S_Form__c SF2 = new S_Form__c();
        public void SF(){

            SF2.Opportunity__c = opp.Id;

public Flow.Interview.S_Form myFlow { get; set; }

public PageReference SFId {
     get {
      PageReference prRef = new PageReference('/apex/VFEdit?id=' + SFOutputId);
      return prRef;
      set { SFid = value; }

     public String SFOutputId {
     get {
     String strTemp = '';

     if(myFlow != null) {
     strTemp = string.valueOf(myFlow.getVariableValue('SFId'));

     return strTemp;

     set { SFOutputId = value; }
  • In your flow, have you assigned Id explicitly using Assignment element in variable ? variable should be defined as Input and Output type. Commented Nov 5, 2015 at 19:27
  • Yes I did. I ended up going a different way and got it to work. Thanks!
    – J. Neilan
    Commented Nov 5, 2015 at 21:37

1 Answer 1


For anyone interested, I ended up getting this to work using the addFields() method in my controller and not needing a Flow after all.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .