You need to sign in to do that
Don't have an account?
Controller Flow null despite specifying Interview in visualforce page
I'm trying to get a value of a flow variable. I'm following this: http://www.salesforce.com/us/developer/docs/pages/Content/pages_flows_getting_values.htm
In the doc it specifies I need a vairable for my flow in my controller and specify that variable on the visualforce page with interview="{FlowVariable"
I've done this, but when I launch the flow from the visualforce page my flow variable is null.
What am I missing? From what I can tell I got everything set right and it should work.
<apex:page standardcontroller="Opportunity" extensions="Closed_Won_Pathway_ext" > <flow:interview name="FlowName" finishLocation="{!IAmFinish}" interview="{!myFlow}" > <apex:param name="varOppID" value="{!Opportunity.id}"></apex:param> </flow:interview> </apex:page>and the controller
public class Closed_Won_Pathway_ext { private final Opportunity opty; //final opportunity where the flow is started public string RecordID; public flow.Interview.Close_Won_This_Opp myFlow {get;set;} //constructed public Closed_Won_Pathway_ext(ApexPages.standardController con){ this.opty = (Opportunity)con.getRecord(); } //get the contractid from the flow public string getRecordId(){ system.debug('myflow: ' + myFlow); //This is Null system.debug(myFlow.varContractID); //This is a null pointer error return myFlow.varContractID; } //finish location public pagereference getIAmFinish(){ PageReference thePage = Page.Celebrate; thePage.getParameters().put('id',getRecordId()); return thePage; } }
So the code is actually correct.
What's happening is the flow has 2 pathways. The first pathway there's a screen, but no finish location. This is fine - we don't want the user to click finish.
The second pathway which is a "success" there's no final screen for the user to click "Finish" so it sort of acts like a headless workflow.
Because of this, my page methods are being called twice - but by the time it's being called a second time with the CORRECT redirect... the flow's redirect has already been set...as NULL. So it doesn't get redirected successfully.
Adding a final screen that forces the user to click "Finish" fixes the problem
All Answers
Also ensure that variables are of type input and output.
let us know if you have any question .
please don't Forget to Mark this as your best answer if it works fine for you
Regards,
Grazitti Team
Web: www.grazitti.com
Variables are already set as input and output and the case sensitivity is correct.
Any other suggestions?
So the flow name does line up correctly to the name of my flow.
I added a whole bunch of debug logs. It appears that my PageReference method is being called twice. Once when I click the button to activate the flow and once again with the flow actually completes.
The second time, myFlow is not null and contains my varContractID from the flow as I expected. I added a bit of logic and according to my debug logs, my redirect has the correct page and ID from varContractID... but the page doesn't actually redirect.
if I hard code the variable for instead of pulling it from the flow... the redirect works just fine.
Any ideas?
So the code is actually correct.
What's happening is the flow has 2 pathways. The first pathway there's a screen, but no finish location. This is fine - we don't want the user to click finish.
The second pathway which is a "success" there's no final screen for the user to click "Finish" so it sort of acts like a headless workflow.
Because of this, my page methods are being called twice - but by the time it's being called a second time with the CORRECT redirect... the flow's redirect has already been set...as NULL. So it doesn't get redirected successfully.
Adding a final screen that forces the user to click "Finish" fixes the problem
<!---<apex:page contentType="c7">-->
<apex:form >
<apex:pageBlock title="My Search1">
<apex:inputText value="{!keyword}"/>
<apex:commandButton value="search" action="{! search_now}"/>
<apex:pageBlockTable value="{!results}" var="r">
<apex:column value="{!r.NAME}"/>
<apex:column value="{!r.TYPE}"/>
<apex:column value="{!r.PHONE}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
and apex
public class c7{
string keyword ;
List<account> results;
//public <account> results{get;set;}
public string getkeyword()
{
Return Keyword;
}
Public List<account> getresults()
{
return results;
}
//piblic void setKeyword (string input)
public void setkeyword (string input)
{
string keyword = input;
}
public pagereference search_now()
{
results=(list<account>)[FIND:keyword IN ALL FIELDS RETURNING account(NAME,PHONE)][0];
return null;
}
I am running into this exact problem when trying to redirect my finish location to the new record created by the flow, however, adding a final flow screen is not a viable option for me since the client wants to be taken to the new record directly without having an extra click. Where you ever able to fins a solution that does not require that final screen?
Thank you, Tamar.