You need to sign in to do that
Don't have an account?
Issue with finish page redirect not working
I am trying to get my finish page from the flow to go to different places based on the result of a decision in the flow. If a case is created in the flow, the finish location is the case, if it's not created, the finish location is a custom object called Conversation__c. What's happening is that it is giving an error
System.NullPointerException: Attempt to de-reference a null object
Class.CaseFlowController.getFinishPage: line 34, column 1
And I don't know how to fix this. Line 34 is the if statement in getFinishPage().
Code for the Controller:
public class CaseFlowController { private final Conversation__c conv; public CaseFlowController(ApexPages.StandardController stdController) { this.conv = (Conversation__c)stdController.getRecord(); } //Calls referenced Flow below public Flow.Interview.createCasefromConversation createCasefromConversation { get; set; } //Gets Id of variables below from flow public String getconversationID() { if (createCasefromConversation==null){ return ''; }else{ System.Debug('ConversationID:' + createCasefromConversation.conversationId); return createCasefromConversation.conversationId; } } public String getcaseID() { if (createCasefromConversation==null) { return ''; } else { System.Debug('CaseId:' + createCasefromConversation.createdCaseId); return createCasefromConversation.createdCaseId; } } //Used for Flow finish location public PageReference getFinishPage(){ if(createCasefromConversation.createdCaseId == ''){ PageReference p = new PageReference('/' + getconversationID()); p.setRedirect(true); system.debug('Page conversation' + p); return p; }else { PageReference p = new PageReference('/' + getcaseID()); p.setRedirect(true); system.debug('Page case' + p); return p; } } }
Here is the code for the Visual Force Page:
<apex:page StandardController="Conversation__c" extensions="CaseFlowController"> <flow:interview name="createCasefromConversation" interview="{!createCasefromConversation}" finishLocation="{!FinishPage}" /> </apex:page>
Any help would be greatly appreciated.
Thanks,
Chris
With the help of Salesforce Developer Support, I was able to get this fixed. All I had to do was add the following line to the getFinishPage method.
if (createCasefromConversation==null) { return new PageReference('');}
So the revised section looks like this:
I'm not sure how that helped but it did.