For clarity, and as I accepted an answer in the last question, I am posting a new question for additional help with new issues. The last question can be reviewed here.

Here are my new issues:

  • When the 'submit' button is pushed on the VF page and the save function from the controller extension is called, the 'congratulations' page shows, as expected, but the record does not actually save.
  • I am having difficulty updating my multiple controller extensions that hold logic and need some assistance with how to change the code. Previously, this code worked when using a custom object, Intake__c. However, I need to change to the standard object, Opportunity, and it is not as simple as changing the object name.

I have updated the main extension to:

public class IntakeExtension {
    public ApexPages.StandardController ctrl;
    public IntakeExtension(ApexPages.StandardController controller) {
             this.ctrl = controller;

    public PageReference save() {
        return Page.Congratulations;
  • This does not give me an error - It's only the 'save' here I'm having trouble with.

  • I have run this 'savetest' with no errors.

    static testMethod void saveTest() {

        Opportunity o = new Opportunity ();
        ApexPages.standardController stdCon = new ApexPages.standardController(o);
        ApexPages.currentPage().getParameters().put('Customer_Name__c','Test Name');        
        IntakeExtension c = new IntakeExtension(stdCon);

Here is one of my logic extensions I need assistance updating code on:

public with sharing class ShouldShowMedSection{
    public ShouldShowMedSection(ApexPages.StandardController paramController) {
       Opportunity = paramController;}
    public ApexPages.StandardController Opportunity {get; set;}
    public Boolean getShouldShowMedSection() {
       Opportunity record = (Opportunity)Opportunity.getRecord();
            record.Personal_Care_Concerns__c != null && record.Personal_Care_Concerns__c.contains('Medication')
            return true;
          return false;
  • When I add ShouldShowMedSection to the extensions list on the VF page, I am met with this error: "Error: Unknown property 'ApexPages.StandardController.Customer_Name__c' "

Here is a portion of the VF page code:

<apex:page standardController="Opportunity" extensions="IntakeExtension,ShouldShowSHSection,ShouldShowSHwECSection,ShouldShowPERSSection,ShouldShowMedSection,ShouldShowRingSection" standardStyleSheets="false" showHeader="false" sidebar="false">
  <apex:stylesheet value="{!$Resource.styleForIntake}"/>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<!-- multistep form -->
<apex:form Id="msform" styleClass="form">
  <!-- progressbar -->
  <ul id="progressbar">
    <li class="active">Client Info</li>
    <li>Residence </li>
    <li>Concerns </li>
    <li>Tech Comfort</li>
  <!-- fieldsets -->
    <h2 class="fs-title">Client Information</h2> 
    <h3 class="fs-subtitle">Here, we will gather information specific to the client.</h3> <br></br>
        Client Name (First and Last Initial): <br></br>
        <span class="required-text">*required</span>
        <apex:inputField styleClass="fieldset" label="Client Name (First and Last Intial):" value="{!Opportunity.Customer_Name__c}"/> 
    <br></br> <br></br>

1 Answer 1

public PageReference save() {
    return Page.Congratulations;

You're not checking to see if the record actually saved. Try:

public PageReference save() {
    // Returns PageReference only on success
    if(this.ctrl.save() != null) {
        return Page.Congratulations;
    // There was an error.
    return null;

As far as the other problem, don't use the name Opportunity for the variable, as that causes a "shadow" effect; you end up referring to the wrong data type/value.

public ShouldShowMedSection(ApexPages.StandardController paramController) {
   standardController = paramController;
public ApexPages.StandardController standardController {get; set;}
public Boolean getShouldShowMedSection() {
   Opportunity record = (Opportunity)standardController.getRecord();
   return record.Personal_Care_Concerns__c != null && record.Personal_Care_Concerns__c.contains('Medication');
  • Thank you - These no longer return errors - Would there be a reason the save function wouldn't save? It's no longer returning the Congratulations page, so there is some error. The logic is also no longer returning the expected section. I'm not sure why. Dec 29, 2020 at 14:35
  • 1
    @AlexisFrisch try adding an apex:pageMessages to your Visual force markup and see what errors you get.
    – sfdcfox
    Dec 29, 2020 at 14:47
  • My logic is working now; it's just the save I'm having some trouble with. I'm not sure how to see what error is causing the record to not save. Would you be willing to assist with this? Dec 29, 2020 at 15:00
  • I am going to be unavailable for a few hours, but I'll be glad to take a deeper look when I'm done.
    – sfdcfox
    Dec 29, 2020 at 15:04
  • Thank you so much! Dec 29, 2020 at 15:04

You must log in to answer this question.

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