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
Brianna BollettieriBrianna Bollettieri 

Creating a visual force page for a custom object

Hi, I'm working on creating a visual force page for a custom object I created. When I go to save it, it says that the standard controller is unknown. So what I'm trying to do is create a page from the Sales Coaching object which is record type specific which you'll see in the coding below. I then have a few sections on the screen. Within each section I have a field set, as well as writing that I want in each section. Below you'll see the apex class and VF page I'm trying to save. Any assistance would be greatly appreciated.

Thanks!

Apex Class
public with sharing class salescoachingRedirect {

    public String retURL {get; set;}
    public String saveNewURL {get; set;}
    public String rType {get; set;}
    public String modeType {get; set;}
    public ApexPages.StandardController sCtrl;
    
    public salescoachingRedirect(ApexPages.StandardController controller) {
        this.sCtrl = controller;
        retURL = ApexPages.currentpage().getParameters().get('retURL');
        rType = ApexPages.currentPage().getParameters().get('International Sales Coaching Note');
        String recordId = ApexPages.currentpage().getParameters().get('Id');
        if(String.isBlank(recordId)){
            modeType = 'Edit';
        }else{
            modeType = 'Detail';
        }
    }
    
    public pageReference save(){
        this.sCtrl.save();        
        String recordId = ApexPages.currentpage().getParameters().get('Id');
        pageReference rPage = null;
        if(!String.isBlank(recordId)){
            rPage = new pageReference('/'+recordId);
        }
        modeType = 'Detail';
        return rPage;
    }
    
    public pageReference openEditView(){
        modeType = 'Edit';
        return null;
    }
    
    public PageReference redirect() {
        PageReference returnURL;
        // Redirect if Record Type corresponds to custom VisualForce page
        IF(rType == 'International Sales Coaching Note') {
              returnURL = new PageReference('/apex/Sales_Coaching_Note__c');
        }
        return returnURL;
    }
}

VF Page
 
<apex:page standardController="Sales_Coaching_Note__c" extensions="salescoachingRedirect" action="{!redirect}" >
<apex:pageMessages />
  <apex:form id="form">
    IF(rType = 'Intl Sales Coaching') {
      <apex:actionFunction name="refreshSection" reRender="form"/>
      <apex:pageBlock title="Opportunity" mode="{!modeType}">
        <apex:pageBlockButtons >
          <apex:commandButton action="{!save}" value="Save" rendered="{!IF(modeType='Edit', true, false)}"/> 
          <apex:commandButton action="{!cancel}" value="Cancel" immediate="true" rendered="{!IF(modeType='Edit', true, false)}"/> 
          <apex:commandButton action="{!openEditView}" value="Edit" immediate="true" rendered="{!IF(modeType='Edit', false, true)}"/>
        </apex:pageBlockButtons>
      <apex:pageBlockSection title="Information">
          <apex:repeat value="{!$ObjectType.Sales Coaching Note.fieldsets.Information}" var="fieldValue">
              <apex:inputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', true, false)}" onChange="refreshSection();"/>
              <apex:outputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', false, true)}"/>
          <apex:page standardController="Coaching_Note__c"> Assign a score for each section 0-10 </apex:page>
          </apex:repeat>
        </apex:pageBlockSection>
      <apex:pageBlockSection title="Opening the meeting/Approach">
          <apex:repeat value="{!$ObjectType.Sales Coaching Note.fieldsets.Score}" var="fieldValue">
              <apex:inputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', true, false)}" onChange="refreshSection();"/>
              <apex:outputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', false, true)}"/>
          <apex:page standardController="Coaching_Note__c"> Gained the customers attention...used an opener that really connected with the customer </apex:page>
          <apex:page standardController="Coaching_Note__c"> Laid out the agenda and process for the meeting </apex:page>
          </apex:repeat>
        </apex:pageBlockSection>        
      <apex:pageBlockSection title="Uncovered needs">
          <apex:repeat value="{!$ObjectType.Sales Coaching Note.fieldsets.Score}" var="fieldValue">
              <apex:inputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', true, false)}" onChange="refreshSection();"/>
              <apex:outputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', false, true)}"/>
          <apex:page standardController="Coaching_Note__c"> Uncovered where customer is in the decision process (decision criteria, influencers, etc.) </apex:page>
          <apex:page standardController="Coaching_Note__c"> Asked General questions about the customer? </apex:page>
          <apex:page standardController="Coaching_Note__c"> Asked Obstacle or opportunity questions? What challenges are they facing? </apex:page>
          <apex:page standardController="Coaching_Note__c"> Asked Outlay questions? How big is the pain? </apex:page>
          <apex:page standardController="Coaching_Note__c"> Asked Acheivement questions to understand what "ideal" looks like? </apex:page>
          <apex:page standardController="Coaching_Note__c"> Asked Leverage questions? Used questions to share key insights? </apex:page>
          <apex:page standardController="Coaching_Note__c"> Asked Summary and Solution questions? The social contract. </apex:page>
          </apex:repeat>
        </apex:pageBlockSection>  
      <apex:pageBlockSection title="Deliver insights/present the solution">
          <apex:repeat value="{!$ObjectType.Sales Coaching Note.fieldsets.Score}" var="fieldValue">
              <apex:inputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', true, false)}" onChange="refreshSection();"/>
              <apex:outputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', false, true)}"/>
          <apex:page standardController="Coaching_Note__c"> Matched features of the contract/program to important Obstacles/Opportunities </apex:page>
          <apex:page standardController="Coaching_Note__c"> Used FAB to describe features, advantages, and benefits of the program </apex:page>
          <apex:page standardController="Coaching_Note__c"> Used stories to back up FAB statement </apex:page>
          <apex:page standardController="Coaching_Note__c"> Involved the customer in the discussion </apex:page>  
          </apex:repeat>
        </apex:pageBlockSection>  
      <apex:pageBlockSection title="Overcoming objections">
          <apex:repeat value="{!$ObjectType.Sales Coaching Note.fieldsets.Score}" var="fieldValue">
              <apex:inputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', true, false)}" onChange="refreshSection();"/>
              <apex:outputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', false, true)}"/>
          <apex:page standardController="Coaching_Note__c"> Clarified or Countered the objection? </apex:page>
          <apex:page standardController="Coaching_Note__c"> Responded, hopefully using a story </apex:page>
          <apex:page standardController="Coaching_Note__c"> Confirmed that the objection is no longer a concern </apex:page>
          </apex:repeat>
        </apex:pageBlockSection>  
      <apex:pageBlockSection title="Close">
          <apex:repeat value="{!$ObjectType.Sales Coaching Note.fieldsets.Score}" var="fieldValue">
              <apex:inputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', true, false)}" onChange="refreshSection();"/>
              <apex:outputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', false, true)}"/>
          <apex:page standardController="Coaching_Note__c"> (Objective: Understand where you stand with customer ow and for the future) </apex:page>
          <apex:page standardController="Coaching_Note__c"> Asked customer to take the next step in a natural conversation flow </apex:page>
          </apex:repeat>
        </apex:pageBlockSection>
      <apex:pageBlockSection title="Comments">
          <apex:repeat value="{!$ObjectType.Sales Coaching Note.fieldsets.Comments}" var="fieldValue">
              <apex:inputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', true, false)}" onChange="refreshSection();"/>
              <apex:outputField value="{!Opportunity[fieldValue]}" rendered="{!IF(modeType='Edit', false, true)}"/>
            </apex:repeat>
        </apex:pageBlockSection>
      </apex:pageblock>
    </apex:form>
</apex:page>