You need to sign in to do that
Don't have an account?
jpb@uhc
Set finishlocation for Flow to be record created by Flow
We have created a flow that creates an Opportunity and we want the "finishlocation" of the flow, where they end up when they click "Finish", to be the newly created Opportunity. I know that we will have to create a VF page and controller to pass the OpptyID (once created) back to the VF page and set as the finishlocation, but can't figure out how to do it. Any ideas?
Sorry, for the late response, but i stumbled upon the resolution myself. Here is the code:
VF Page -
Here is the Class -
All Answers
You can create a button (Finish) , a VF page and a controller.
Override the view page of opportunity wth the VF page you will create.
Once the Opp is created the record will go to your VF page and then you can click on the Button to call finish from the controller.
Basically let the finish button be the action handler for the creation of the opportunity as
On click of finish Save the opportunity
redirect the user to the Detail page of the Newly created opportunty on Click of Finish or you can send him to a page saying that the opportunity has been created
Please mark this as solved if your problem is solved
Sorry, for the late response, but i stumbled upon the resolution myself. Here is the code:
VF Page -
Here is the Class -
if we don't want to click finish button how redirectly to detail page .
Any hints on a test class for this controller? This solution works brilliantly, but I'd like to cover the testing.
Can you highlight which spots we would need to fill in with the name of our own flow names and variables?
Thank you!
Hi,
In Below code from where we are getting Opptyid .
PageReference p = new PageReference('/apex/opportunityProductEntry?id=' + getmyID() + '&addTo=' + getmyID() + '&retURL=%2F006%2Fe&sfdc.override=1');
To what does ''/apex/opportunityProductEntry refer
Also, what is e&sfdc.override=1 ?
URL No Longer Exists
You have attempted to reach a URL that no longer exists on salesforce.com
screen, with a return URL of salesforce.com/null.
Any help would be extremely appreciated!
Can youhelp with the test class for this extensions??
thanks,
Known Issue
Not able to get record IDs from Flow to VisualForce if create record is the last step in flow
https://developer.salesforce.com/forums/?id=906F000000097pVIAQ
Idea
Flow Designer needs a simple way to "end" a flow by navigating to a record
https://success.salesforce.com/ideaView?id=08730000000ipeVAAQ
I have seen several blogs regarding setting the landing page for flow to the newly created record using VF page and apex controller, but not sure what exactly should be the code for the custom button from where this flow is being called. I have a scenario wherein I need to create an opportunity after clicking on the "Create Opportunity" button on case object which should land to the newly created opportunity record page when I click on "Finish" button.
Here is the code for reference:
I am not sure what exactly shoule be mentioned in the return URL for this custom button. Could anyone please help with that?
Custom Detail Page Button "Create Opportunity":
/flow/TestOpp?varAccountId={!Case.AccountId}&varCaseID={!Case.Id} &varOppOwner2={!Account.OwnerId}&retURL=/apex/CreateOppFromSRPage2
Here "varOppId" is the output type variable which I created in my Flow to capture the Opportunity record ID
Thank you!
This is regarding flow finish landing to the newly created record. I have "Opportunity__c" (lookup field) on case object. Also there is a service_request__c (lookup to case) on Opportunity object. My requirement is I need to create an opportunity after clicking on the "Create Opportunity" button on case object which should land to the newly created opportunity record page when I click on "Finish" button. Though I am able to land it to the case detail page from where I am creating opportunity but not able to make it landing to the newly created opportunity record.
Here is the URL of my "Create Opportunity" button on case object-
/flow/CreateOppFromSR?varAccountId={!Case.AccountId}&varCaseID={!Case.Id}&varCaseNumber={!Case.CaseNumber}&varProductId={!Case.ProductId}&retUrl =/{!Case.Opportunity__c}
Any help would be greatly appreciated.
Regards,
Prachi
My VF page still doesn't redirect to the new record created by flow. Here is my VF Page and Controller:
VF Page
Controller
Can you suggest something please.
Thank You!
Is there any solution for finishpage. It worked great when I have extension controller. However I couldn't create test class. Can anyone help with test class thanks.
<apex:page standardController="GW_Volunteers__Volunteer_Job__c" tabStyle="GW_Volunteers__Volunteer_Job__c" extensions="FlowRedirectController"> <flow:interview name="GIGI_SyncProgVolToPlay_ProgVolJob1" interview="{!redirectTo}" finishLocation="{!finishLocation}" > <apex:param name="VarId" value="{!GW_Volunteers__Volunteer_Job__c.Id}"/> <apex:param name="AlreadySynced" value="{!GW_Volunteers__Volunteer_Job__c.SyncedSuccessfully__c}"/> <apex:param name="VarPrgName" value="{!GW_Volunteers__Volunteer_Job__c.Name}"/> </flow:interview> </apex:page>
Extension class:
Public class FlowRedirectController{
public FlowRedirectController(ApexPages.StandardController controller) {
}
Public Flow.Interview.GIGI_SyncProgVolToPlay_ProgVolJob1 redirectTo {get; set;}
public FlowRedirectController() {
Map<String, Object> redirectURL = new Map<String, Object>();
//vFinishLocation is the name of a variable from your Flow containing the Id of your newly created Opportunity
redirectURL.put('VarId','https://gigisplayhouse--volprogvf.cs45.my.salesforce.com/');
redirectTo = new Flow.Interview.GIGI_SyncProgVolToPlay_ProgVolJob1(redirectURL);
}
Public PageReference getFinishLocation(){
string strID = ApexPages.currentPage().getParameters().get('Id');
String finishLocation;
if(redirectTo != null) {
finishLocation = (string) redirectTo.getVariableValue('VarId');
}
else
{
finishLocation=strID;
}
PageReference send = new PageReference('/' + finishLocation);
send.setRedirect(true);
return send;
}
}
Test class:
@isTest
private class FlowRedirectControllerTest{
static testmethod void SetVariablesTests() {
//Insert Campaign
Campaign sCmp = new Campaign(Name='TestClassCamp',Status='Active');
insert sCmp;
System.debug('inserted campaigns . athi ' );
// Retrieve the new campaign
sCmp = [SELECT Id,Name FROM Campaign WHERE Id =:sCmp.Id LIMIT 1];
//Insert prog job
GW_Volunteers__Volunteer_Job__c vol=new GW_Volunteers__Volunteer_Job__c(Name='TestJob', GW_Volunteers__Campaign__c =sCmp.id, GW_Volunteers__Description__c ='Hellow', GW_Volunteers__Display_on_Website__c=true);
insert Vol;
// System.debug('inserted Jobs. athi ' );
// Retrieve the new prog Job
vol = [SELECT Id,Name, GW_Volunteers__Campaign__c, GW_Volunteers__Display_on_Website__c FROM GW_Volunteers__Volunteer_Job__c WHERE Id =:vol.Id LIMIT 1];
Test.startTest();
//VFFLow is the name of the VisualForce page which you create
PageReference pageRef = Page.GIGI_SyncProgJobToPlayVF;
Test.setCurrentPage(pageRef);
System.currentPageReference().getParameters().put('Id',Vol.Id);
FlowRedirectController testCtrl = new FlowRedirectController();
testCtrl.redirectTo = new Flow.Interview.GIGI_SyncProgVolToPlay_ProgVolJob1(new Map<String, Object>());
testCtrl.redirectTo.start();
testCtrl.getFinishLocation();
Test.StopTest();
// System.assertEquals(testCtrl.getFinishLocation().getUrl(), 'https://gigisplayhouse--volprogvf.cs45.my.salesforce.com/');
}
}
Thanks in advance