You need to sign in to do that
Don't have an account?
Visual Flow inside Visualforce Page with Apex Controller - Lag in displaying values
I have a curious case where I have a Visual Flow embedded in a Visualforce Page. This works fine.
I have a few variables in the Flow which are exposed to the Visualforce Page (For example, contact Name, Phone, and Email) which I want to display during the entire Flow process.This works fine except one problem:
The variables aren't displayed when they are set in the Flow. I have to go to an additional screen by clicking Next or Previous to get the values back in the Visualforce Page when they have already been set in the Flow.
Anyone seen this similar type behavior? It's probably something super simple but I just don't see it at the moment.
Here's a good example on how to display flow variables within a Visualforce page:
http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_flows_advanced.htm
How are you setting variables in the flow?
I've put some sample code below for a Flow that just searches for a Contact by email and displays the FirstName in the VF container, to see it changing as the variable changes in the Flow. In the flow, the variable for the firstname is assigned from a record search and stored in a variable 'vContactFirstName'. I changed the variable with an assignment element.
Hope that helps, we'd be happy to look at your controller and page code also.
-cj
/* Controller */
public class ContactSimple {
public Flow.Interview.ContactSearch myflow {get;set;}
public String firstName;
public String getFirstName() {
// Access flow variables as simple member variables with get/set methods
if(myflow==null) return 'na';
else return myflow.vContactFirstName;
}
}
<!-- VF Container Page -->
<apex:page Controller="ContactSimple" tabStyle="Contact" >
<flow:interview name="ContactSearch" interview="{!myflow}" reRender="nameSection" />
<apex:outputText id="nameSection" value="Contact First Name: {!firstName}"/>
</apex:page>
All Answers
Here's a good example on how to display flow variables within a Visualforce page:
http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_flows_advanced.htm
How are you setting variables in the flow?
I've put some sample code below for a Flow that just searches for a Contact by email and displays the FirstName in the VF container, to see it changing as the variable changes in the Flow. In the flow, the variable for the firstname is assigned from a record search and stored in a variable 'vContactFirstName'. I changed the variable with an assignment element.
Hope that helps, we'd be happy to look at your controller and page code also.
-cj
/* Controller */
public class ContactSimple {
public Flow.Interview.ContactSearch myflow {get;set;}
public String firstName;
public String getFirstName() {
// Access flow variables as simple member variables with get/set methods
if(myflow==null) return 'na';
else return myflow.vContactFirstName;
}
}
<!-- VF Container Page -->
<apex:page Controller="ContactSimple" tabStyle="Contact" >
<flow:interview name="ContactSearch" interview="{!myflow}" reRender="nameSection" />
<apex:outputText id="nameSection" value="Contact First Name: {!firstName}"/>
</apex:page>
Thanks for the information!
I am not using an Assignment Element, I am storing directly in variable from one of the screens dropdown choices that returns the list and puts the selected item in the variable.
Let me see if that is the difference.
Everything else is pretty much the same. Just seems to lag one screen behind. Weird!
Thanks. I resolved it by comparing my code to yours. Looks like it was a typo IF statement in my controller that wasn't getting refired.
Thanks!
Great!
When I created new record Lead or Opportunity by visual flow and then I want to get new Id to Visualforce page don't need finish page redirect to detail page.Have any idea?
I am very curious to know the test class for this. Can you please share some tips? I too have a Flow which is embedded inside VF page, which has a controller method. I need to write test class for that controller..