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
Admin FactorAdmin Factor 

The Flow has two different behaviours depending on where you start it and only one is correct

I have created a Flow named Prueba_Casos which has different screens (including Previous, Next and Finish buttons) and I use it to create a new register Case.

Also, I developed a controller Class named CaseFlowController.apxc and a Visualforce Page (VFP) named FlowPage.vfp I used it to declare a finishlocation at the VFP which is receiving the PageReference from the function getOID of the class with {!OID}. Also the flow interview="{!myflow}" at the VFP which receives the ID (getmyID) of the new Case from the class.

The variable var_case_id does exist and it is Text Data Type and is also Input and Output (Flow Designer variable definition). When I create the new register Case at the Flow Designer I assign the the record ID to the variable to reference it on my flow too. The code seems right because there are no errors and everything has its logic:

FlowPage.vfp
<apex:page Controller="CaseFlowController" TabStyle="Case">
    <flow:interview name="Prueba_Casos" interview="{!myflow}" finishlocation="{!OID}" />
</apex:page>
CaseFlowController.apxc
public class CaseFlowController {
    public Flow.Interview.Prueba_Casos myFlow { get; set; }
    
    public String getmyID() {
    	if (myFlow==null) return '';
    	else return myFlow.var_case_id;
    }
    
    public PageReference getOID(){
    	PageReference p = new PageReference('https://cs63.salesforce.com/500/o');
        p.setRedirect(false);
    	return p;
    }
}
The problem is the two different behaviours:
1) The incorrect one: I created a custom button at the Case layout called "Reclamaciones":
/flow/Prueba_Casos?CaseID={!Case.Id}&retURL=/{!Case.Id}
On click you start the flow, but at the end it doesn't redirect you to the finishlocation specified (https://cs63.salesforce.com/500/o).

2) The correct one: If you go to Setup > Visualforce Pages and then click on the icon next to the FlowPage you start the flow and in the end it does redirect you to the finishlocation specificied (https://cs63.salesforce.com/500/o).

The behaviour of the button is the one that I need to work. Do you know what is happening?
Best Answer chosen by Admin Factor
Rakesh51Rakesh51
Its working as per you design, try to change your code

/flow/Prueba_Casos?CaseID={!Case.Id}&retURL=/500/o

P.S. :- if you dont want ot recdirect your users to new record then, no need to use VF and Apex

All Answers

Rakesh51Rakesh51
Its working as per you design, try to change your code

/flow/Prueba_Casos?CaseID={!Case.Id}&retURL=/500/o

P.S. :- if you dont want ot recdirect your users to new record then, no need to use VF and Apex
This was selected as the best answer
Admin FactorAdmin Factor
@Rakesh45 What if I want to redirect to the created Case in mode "Edit"? I mean the screen after you click the button "Edit".
Rakesh51Rakesh51
Then you have to use Apex and Visualforce page