You need to sign in to do that
Don't have an account?
Dave Berenato
Finish Location of Apex Flow to load Standard Controller Page for New Record
Hi everyone,
I have a Visualforce page that checks for an existing Lookup record. If it does not exist, it runs a Flow Interview to create one, and if it does exist, it loads a Visualforce webform I made that uses Standard Controller for that "Application__c" custom object.
My only issue is I need the <flow: interview> FinishLocation to pull a variable ID from the record created in the Visual Workflow. How can I achieve this and reference it in the Visualforce Page?
I have a Visualforce page that checks for an existing Lookup record. If it does not exist, it runs a Flow Interview to create one, and if it does exist, it loads a Visualforce webform I made that uses Standard Controller for that "Application__c" custom object.
My only issue is I need the <flow: interview> FinishLocation to pull a variable ID from the record created in the Visual Workflow. How can I achieve this and reference it in the Visualforce Page?
public class FAIRAssistanceApplication { public FAIRAssistanceApplication (ApexPages.StandardController controller) { } public ID getAccId = System.currentPagereference().getParameters().get('var_AccountID'); public Flow.Interview.NewFAIRAppAuto NewAppFlow{get;set;} public String getAccountId(){ return getAccId; } public ID AppId = NewAppFlow.var_AppID; public PageReference getAppId(){ if(NewAppFlow != null) AppId = NewAppFlow.var_AppID; PageReference send = new PageReference('/' + NewAppFlow.var_AppID); send.setRedirect(true); return send; } }
<apex:page showheader="false" standardController="Application__c" extensions="FAIRAssistanceApplication"> <apex:pageblock rendered="{!IF(ISBLANK(Application__c.Property_Account__c),TRUE,FALSE)}"> <flow:interview name="NewFAIRAppAuto" interview="{!NewAppFlow}" finishLocation="{!AppId}')}"> </flow:interview> </apex:pageblock> <apex:form rendered="{!IF(NOT(ISBLANK(Application__c.Property_Account__c)),TRUE,FALSE)}"> <p>{!Application__c.Property_Account__r.Name}</p> <p>{!Application__c.Name}</p> <p>Employer: <apex:inputField value="{!Application__c.Employer_Position_1__c}"/></p> <apex:commandButton id="saveBtn" value="Save" action="{!save}" /> </apex:form> </apex:page>
What doesn't work exactly? All seems correct if NewAppFlow.var_AppID is at least an output field.
There is just a typo above for finishLocation
https://developer.salesforce.com/forums/?id=9060G000000BcrtQAC
So I have this extension as above:
And I go to the URL:
I get the below error.
Error message for the above code is "Variable does not exist: AppId"
I tried declaring the variable but that did not help (see line 22):
So when I went to:
I end on:
When I wanted it to end on:
Where "a184D000001h5BY" is the var_AppId created by the flow (this worked successfully by the way, so the last piece is just the FinishLocation.
Thank you!
I don't know if your code is complete or just an excerpt.
Only complete code and complete flow can be really fixed.
Hi Alain,
That's the full code:
Visualforce Page:
Which if the URL has an Account with no Application will run the below flow:
(var_AccountID in, var_AppID out)
And then using the below class will redirect back to the Visualforce Page with the Standard Controller pulling the new AppId:
So the only piece I'm missing is to have the FinishLocation equal the var_AppID created in the flow.