1

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.

2

1 Answer 1

0

Variable controller is not assigned, therefore controller.save() is doing nothing. I would assign it in constructor with stdController (see below)

    public WorkflowControllerExtension(ApexPages.StandardController stdController) {
        this.wf = (Workflow__c)stdController.getRecord();
        this.controller = stdController;
    }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .