My requirement is that after save of a record of custom object (Workflow__c
), the user is redirected to the home page.
I have set the override for the View
action on the custom object to be visualforce page WorkflowOverride
. LEX/Mobile are also set to inherit the Classic override. See my code below:
Visualforce Page - WorkflowOverride.vfp
<apex:page standardController="Workflow__c" extensions="WorkflowControllerExtension" lightningStylesheets="true">
<apex:detail inlineEdit="true" relatedList="true"/>
<apex:form>
<apex:pageBlock>
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller Extension - WorkflowControllerExtension.apxc
public with sharing class WorkflowControllerExtension {
private final Workflow__c wf;
private ApexPages.StandardController controller;
public WorkflowControllerExtension(ApexPages.StandardController stdController) {
this.wf = (Workflow__c)stdController.getRecord();
}
public PageReference save() {
controller.save();
PageReference result= new PageReference('https://*mydomain.lightning.force.com/lightning/page/home');
result.setRedirect(true);
return result;
}
}
When viewing the record detail in LEX it appears as if my VF page does nothing. When I try to override the Edit
action I lose the ability to inline edit the record detail page. Clicking the edit button just brings me my VF page.
Where am I going wrong? After reviewing the documentation and many other posts I don't understand where I am going wrong.