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
Shawn ReichnerShawn Reichner 

Help with Site VisualForce Page Not Populating fields on Case Record


I am building a "Site" for guest users to submit a Case for support.  I have the site built, the visualforce page, and a controller extension built to add an attchment.  When the case is submitted form the site, it creates a Case record in Salesforce, the attachment shows under the notes and attachments related list, but the subject and description fields that were filled out on the Site are not being populated on the case record.  

I am at a loss here as to why they are not working, and I am a new developer so I very well could have missed something very easy.  Please look over the following code for my VF Page, and the controller extension, and if available please help me figure out how to get the subject and description fields to populate on the case record with the information that was submitted via the site submission.  

Thank you in advance for your time and help!

VF Page

<apex:page standardcontroller="Case" extensions="caseattachment"
<img src="{!$resource.AVISPL_Logo2}"></img><b/><b/>
    <apex:form >
    <apex:pageBlock >
<apex:pageBlockSection title="Hello, Thank You For Reporting Your Incident!  A Salesforce Platform Engineer Will Be In Touch Shortly. " columns="1" showHeader="True" collapsible="False">
<apex:pageMessages />

        <apex:pageBlock >
        <apex:inputField value="{!Case.CaseNumber}"/>
            <apex:pageBlockSection title="Subject">
                <apex:inputText value="{!Case.subject}" />

            <apex:pageBlockSection title="Attachment Or ScreenShot">                                   
            <apex:inputFile id="fileToUpload" value="{!fileBody}" filename="{!fileName}" styleClass="input-file"/>                            

            <apex:pageBlockSection title="Tell Us About The Incident">
                <apex:inputTextarea value="{!Case.Description}" rows="8" cols="80" />

            <apex:commandButton value="Submit Incident" action="{!Save}" />

Controller extension

public class caseattachment
public case objcase{get;set;}
public Attachment myAttachment{get;set;}
public string fileName{get;set;} 
public Blob fileBody{get;set;}

    public caseattachment(Apexpages.standardcontroller controller)
        objcase = new case();
        myAttachment =new Attachment();
    public pagereference save()
        insert objcase;
        myAttachment  = new Attachment();
              Integer i=0;
              myAttachment .clear();
              myAttachment.Body = fileBody;
              myAttachment.Name = this.fileName; 
              myAttachment.ParentId =;             
              insert myAttachment;                 
        pagereference pr = new pagereference('/';                           
        return pr;
The problem here is that you are saving the 'objcase' record in your controller, but the input fields on the page are bound to the 'Case' record from the standard controller.

I wouldn't use the standard controller myself - instead I'd convert your extension controller to a custom controller and bind the fields on the page to the objcase record.