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
azar khasimazar khasim 

Data not getting stored in Custom Object while using Visualforce Page from Sites.

I am working on Sites and have created a VisualForce Page on Custom Object (Booking Link). While using Visualforce Page in Preview it was creating a record,  But While using the same Visualforce Page in Site the data was not getting stored in Custom Object(Booking Link).

Please Help me out from this...

My Visualforce Page Code:

<apex:page controller="BookingController">
    <apex:form >
        <apex:sectionHeader title="Person Customer Edit" subtitle="New Customer"/>
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="cancel"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Customer Information" collapsible="false" columns="2">           
                <apex:inputField value="{!booking.Salutation__c}"/>
                <apex:inputField value="{!booking.Name}"/>
                <apex:inputField value="{!booking.First_Name__c}"/>
                <apex:inputField value="{!booking.Date_Of_Birth__c}"/>
                <apex:inputField value="{!booking.Middle_Name__c}"/>
                <apex:inputField value="{!booking.Wedding_Anniversary__c}"/>
                <apex:inputField value="{!booking.Last_Name__c}"/>
                <apex:inputField value="{!booking.Mobile__c}"/>
                <apex:inputField value="{!booking.Gender__c}"/>
                <apex:inputField value="{!booking.Alternate_Mobile__c}"/>
                <apex:inputField value="{!booking.Relation__c}"/>
                <apex:inputField value="{!booking.Phone__c}"/>
                <apex:inputField value="{!booking.Father_Husband__c}"/>
                <apex:inputField value="{!booking.Other_Phone__c}"/>
                <apex:inputField value="{!booking.Pan_Number__c}"/>
                <apex:inputField value="{!booking.Home_Phone__c}"/>
                <apex:inputField value="{!booking.Aadhar_Number__c}"/>
                <apex:inputField value="{!booking.Email__c}"/>  
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Professional Information" collapsible="false" columns="1">
                <apex:inputField value="{!booking.Profession__c}"/>
                <apex:inputField value="{!booking.Designation__c}"/>
                <apex:inputField value="{!booking.Professional_Email__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Office Address" collapsible="false" columns="1">
                <apex:inputField value="{!booking.Employed_by__c}"/>
                <apex:inputField value="{!booking.OfficeStreet__c}"/>
                <apex:inputField value="{!booking.OfficeCity__c}"/>
                <apex:inputField value="{!booking.OfficeState__c}"/>
                <apex:inputField value="{!booking.OfficeCountry__c}"/>
                <apex:inputField value="{!booking.OfficePinCode__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Children School Address" collapsible="false" columns="1">
                <apex:inputField value="{!booking.School_Name__c}"/>
                <apex:inputField value="{!booking.SchoolStreet__c}"/>
                <apex:inputField value="{!booking.SchoolCity__c}"/>
                <apex:inputField value="{!booking.SchoolState__c}"/>
                <apex:inputField value="{!booking.SchoolCountry__c}"/>
                <apex:inputField value="{!booking.SchoolPinCode__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Address Information" collapsible="false" columns="2">   
                <apex:inputField value="{!booking.BillingStreet__c}"/>
                <apex:inputField value="{!booking.ShippingStreet__c}"/>
                <apex:inputField value="{!booking.BillingCity__c}"/>
                <apex:inputField value="{!booking.ShippingCity__c}"/>
                <apex:inputField value="{!booking.BillingState__c}"/>
                <apex:inputField value="{!booking.ShippingState__c}"/>
                <apex:inputField value="{!booking.BillingCountry__c}"/>
                <apex:inputField value="{!booking.ShippingCountry__c}"/>
                <apex:inputField value="{!booking.BillingPinCode__c}"/>
                <apex:inputField value="{!booking.ShippingPinCode__c}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller Class:

public class BookingController {
    public Booking_Link__c booking {get;set;}
    
    public BookingController(){
        booking = new Booking_Link__c();
    }
    
    public PageReference save(){
        try {  
            INSERT booking;
        }
        catch (Exception e) {
            ApexPages.addMessages (e);
            return null;
        }
        PageReference pr = new ApexPages.StandardController(booking).view();
        return pr;
    }
    
    public void cancel(){
        booking = new Booking_Link__c();
    }
}

Please give me a solution for this...
azar khasimazar khasim
This is the Error Page i was getting after clicking on Save Button