function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Delinda TinkeyDelinda Tinkey 

Get multiple variables from flow to define the destination URL when flow is complete

I have a working controller (below) that passes a variable from a flow to a destination URL (finishlocation) when the flow is complete.

As I am still learning APEX, can someone explain how I can get more than one variable from the flow and add it as parameters to my finishlocation?

For example:

PageReference pageRef = new PageReference('/' + flowContactId + ? + Id2 + & + Id3 )....etc.

THANK YOU


Controller:

public class SurveyFlowController {
public Flow.Interview.Survey_Flow_Test myflow {get;set;}
    
// Set the page reference accessor methods
public PageReference finishlocation {
get {
PageReference pageRef = new PageReference('/' + flowContactId );
pageRef.setRedirect(true);
return pageRef;
}
set { finishlocation = value; }
}
 
// Set the accessor methods for the flow output variable

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

if(myflow != null) {
strTemp = string.valueOf(myflow.getVariableValue('varContactID'));
}
return strTemp;
}
set { flowContactId = value; }

}
}


Visualforce Button:
<apex:page Controller="SurveyFlowController" > <flow:interview name="Survey_Flow_Test" interview="{!myflow}" finishlocation="{!finishlocation}" /> </apex:page>
Best Answer chosen by Delinda Tinkey
@Karanraj@Karanraj
Similar the variable ​varContactID get the value and store it in the controller variable and included in the parameter.
Check the below code for sample
public class SurveyFlowController {
public Flow.Interview.Survey_Flow_Test myflow {get;set;}
    
// Set the page reference accessor methods
public PageReference finishlocation {
get {
PageReference pageRef = new PageReference('/' + flowContactId +'?'+ID2+'&'+ID3);
pageRef.setRedirect(true);
return pageRef;
}
set { finishlocation = value; }
}
 
// Set the accessor methods for the flow output variable

public String flowContactId {
get {
String strTemp = '';
if(myflow != null) {
strTemp = string.valueOf(myflow.getVariableValue('varContactID'));
}
return strTemp;
}
set { flowContactId = value; }

}

public List<String> getID2() { 
 if (myflow == null) { 
  return null;
 } 
 else { 
  return (List<String>)myflow.variable2;
 } 
}


public List<String> getID3() { if (myflow == null) {   return null;  } else {   return (List<String>)myflow.variable3;  } }

}
Check this link - ​https://help.salesforce.com/HTViewHelpDoc?id=pages_flows_getting_values.htm&language=en_US