[SalesForce] Name error in Visualforce Page

I am trying to create a simple VF page to view case using the Apex Page Parameters. However, I get the following error:

The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.

Here is the VF Page

<apex:page standardController="Case" extensions="CaseStatusFollowUpClass" sidebar="true" readOnly="true">
  <apex:pageblock >
    <apex:pageBlockSection title="Contact Information" columns="2">
      <apex:outputLabel > Contact </apex:outputLabel>
      <apex:outputText > {!CurrentCase.SuppliedName}</apex:outputText>
      <apex:outputLabel > Email </apex:outputLabel>
      <apex:outputText > {!CurrentCase.SuppliedEmail}</apex:outputText>
    </apex:pageBlockSection>
    <apex:pageBlockSection title="Case Information" columns="2">
      <apex:outputLabel > Subject</apex:outputLabel>
      <apex:outputText > {!CurrentCase.Subject}</apex:outputText>
      <apex:outputLabel > Created Date </apex:outputLabel>
      <apex:outputText > {!CurrentCase.CreatedDate}</apex:outputText>
      <apex:outputLabel > Priority</apex:outputLabel>
      <apex:outputText > {!CurrentCase.Priority}</apex:outputText>
      <apex:outputLabel > Status</apex:outputLabel>
      <apex:outputText > {!CurrentCase.Status}</apex:outputText>
    </apex:pageBlockSection>
  </apex:pageblock>
</apex:page>

And here is the extension class:

public with sharing class CaseStatusFollowUpClass 
{
  Public Id CurrentCaseId =   System.currentPageReference().getParameters().get('Id'); 
  public Case CurrentCase {get;set;} 
  public CaseStatusFollowUpClass(ApexPages.StandardController controller) 
  {
    System.debug('ID: ' + CurrentCaseId);
    this.CurrentCase = (Case)controller.getRecord();
    CurrentCase = [Select Id, CaseNumber, SuppliedEmail, SuppliedName, CreatedDate, Priority, Status, Subject 
                   From Case Where Id= :CurrentCaseId];
    System.debug('CurrentCase : ' + CurrentCase);

  }
}

Best Answer

The error...

The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.

... Is nothing to do with your Visualforce page nor your class. It's what you're saving the page as!

When you're giving your Page a name here...

enter image description here

... You need to ensure the Name only contains characters a-z, A-Z and 0-9. The Label can have spaces etc... in it, however, the Name must conform to these stricter rules.

Related Topic