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
Stephanie DodsonStephanie Dodson 

Customizing flow finish location

I am new to coding.  I need a little assistance.  I have embedded my flow in a visualforce page and I am trying to create a custom controller to have the flow finish with redirecting the user to the newly created record.

Page:

<apex:page Controller="SplitCaseController">
<flow:interview name="Split_Case" interview="{!myFlow} finishLocation="/{!FinishPage}">
<apex:param name="CurrentCaseID" value="{!Case.Id}"/>
<apex:param name="CurrentUserID" value="{!$User.Id}"/>
</flow:interview>
</apex:page>

Controller

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class SplitCaseController {

public Flow.Interview.Split_Case myFlow { get; set; }

public String getmyID() {
if (myFlow==null) return '';
else return myFlow.NewCaseID;
}

public PageReference getFinishPage(){
PageReference p = new PageReference('/' + getmyID());
p.setRedirect(true);
return p;
}}

But every time I try to save the page I get the error "Unknown property 'SplitCaseController.Case'

Help!
shikher goelshikher goel
Hi Stephanie,

Reason for your error is from this line <apex:param name="CurrentCaseID" value="{!Case.Id}"/> as in this , you are trying to use {!case.id) but there is no variable declared as Case in your controller.

Instead of <apex:param name="CurrentCaseID" value="{!Case.Id}"/>  , do this <apex:param name="CurrentCaseID" value="{!MyId}"/> .

This will resolve your issue.


Thanks,
Shikher Goel
Stephanie DodsonStephanie Dodson
Hi Shikher,

Thank you for the response, but the "myID" variable is supposed to retrieve the id of the case that is created during the flow.

The line<apex:param name="CurrentCaseID" value="{!Case.Id}"/>  is meant to pass the id of the case that the flow is being launched from to the flow. 

So I don't believe your resolution will work for me.
shikher goelshikher goel
Hi Stephanie,

Ok. So then in case we need to have Case Variable in page  :

<apex:page standardController="Case" extensions="SplitCaseController">
<flow:interview name="Split_Case" interview="{!myFlow} finishLocation="/{!FinishPage}">
<apex:param name="CurrentCaseID" value="{!Case.Id}"/>
<apex:param name="CurrentUserID" value="{!$User.Id}"/>
</flow:interview>
</apex:page>

And Add one constructor into class
public SplitCaseController(ApexPages.StandardSetController controller)
{
}

Thanks,
Shikher Goel
Stephanie DodsonStephanie Dodson
Hi Shikher,

Thank you for the response.

I added that line to my class as such:

public class SplitCaseController {

public SplitCaseController(ApexPages.StandardSetController controller)
{
}
public String getmyID() {
if (myFlow==null) return '';
else return myFlow.NewCaseID;
}

public PageReference getFinishPage(){
PageReference p = new PageReference('/' + getmyID());
p.setRedirect(true);
return p;
}}


and then added to the visualforce page as such:

<apex:page standardController="Case" extensions="SplitCaseController">
<flow:interview name="Split_Case" finishLocation="/{!FinishPage}">
<apex:param name="CurrentCaseID" value="{!Case.Id}"/>
<apex:param name="CurrentUserID" value="{!$User.Id}"/>
</flow:interview>
</apex:page>

but when I try to save the page I get the following error:
[Error] Error: Unknown constructor 'SplitCaseController.SplitCaseController(ApexPages.StandardController controller)'

[Quick Fix] Create Apex method 'SplitCaseController.SplitCaseController(ApexPages.StandardController controller)'

Any advice?
 
shikher goelshikher goel
Hi Stephanie,

First you need to save the controller . Once it is saved..Then copy the code of Visualforce page and save.

YOu are trying to save first VF code but it needs controller code which is not present currently . Thats why you are getting the error.

Thanks,
Shikher Goel
Stephanie DodsonStephanie Dodson
Hi Shikher,

I am very new to this part of SF (this is my first page and class) so maybe I am missing something very obvious but I have made the changes to the controller first and hit save, then went to my page and made the changes and hit save and still getting the same error?