• Suveer Mohunlal
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi guys,

Im having trouble getting my visualforce page to save data to my custom object. Im working in sandbox and using sites to expose my page publicly to get input from guest users. It works when I enter data from the preview but not when I open the link. I have checked my 'Public Access Settings' and gave the correct permissions for Org, Object and Field level security. I've tried everything from related posts but nothing seems to work.

Here is my code:

Visualforce page:
 
<apex:page standardStylesheets="false" sidebar="false" showHeader="false" standardController="Candidate__c" extensions="MyCandidateController">
<apex:form style="font:poppins;">
 
<apex:pageBlock >

        <center> <apex:image url="{!$Resource.Khono}" width="375" height="92"/> </center>
        <apex:styleSheet value="{!$Resource.Khonology_CSS_Style}"/>
        <apex:styleSheet value="{!$Resource.Khono_Font_Style}"/>
        <apex:styleSheet value="{!$Resource.Khono_Button_Style}"/>
        <apex:styleSheet value="{!$Resource.Khono_All_Min_Style}"/>


 <form id="contact-form">  
        <apex:pageBlockSection title="Personal Information">


            <apex:pageBlockSectionItem >
                
                <apex:inputfield html-placeholder="First Name" id="Name" value="{!c.Name}" />
            </apex:pageBlockSectionItem>
    
             <apex:pageBlockSectionItem >
                
                <apex:inputfield html-placeholder="Last Name" id="Surname" value="{!c.Surname__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
               <apex:outputLabel ><th><td>Gender</td></th></apex:outputLabel>
                <apex:inputField html-placeholder="Gender" id="Gender" value="{!c.Gender__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
                <apex:outputLabel ><th><td>Ethnicity</td></th></apex:outputLabel>
                <apex:inputField id="Ethnicity" value="{!c.Ethnicity__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
                <apex:outputLabel ><th><td>Country of Birth</td></th></apex:outputLabel>
                <apex:inputField id="COB" value="{!c.Country_of_Birth__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
               
                <apex:inputField html-placeholder="ID Number" id="IDno" value="{!c.ID_Number__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
                
                <apex:inputField html-placeholder="Email" id="Email" value="{!c.Email_Address__c}"/>
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
               
                <apex:inputField html-placeholder="Contact Number" id="ContactNo" value="{!c.Contact_Number__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
                <apex:outputLabel ><th><td>Residential Address Province</td></th></apex:outputLabel>
                <apex:inputField id="Province" value="{!c.Residential_Address_Province__c}" />
            </apex:pageBlockSectionItem>
    
</apex:pageBlockSection>

<apex:pageBlockSection title="Qualification">    

    
            <apex:pageBlockSectionItem >
                <apex:outputLabel >University</apex:outputLabel>
                <apex:inputField id="Uni" value="{!c.University__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Qualification</apex:outputLabel>
                <apex:inputField id="Qualification" value="{!c.Qualification__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
                
                <apex:inputField html-placeholder="Major Subjects" id="Subjects" value="{!c.Major_Subjects__c}" />
            </apex:pageBlockSectionItem>
   
</apex:pageBlockSection>
 </form>    


    <apex:pageBlockButtons >    
        <apex:commandButton id="Save" action="{!Save}" value="Save" styleClass="btn .btn-primary"/>
        <apex:commandButton id="Cancel" action="{!Cancel}" value="Cancel" styleClass="btn .btn-primary"/>
    </apex:pageBlockButtons>



</apex:pageBlock>

    
</apex:form>
</apex:page>






Controller:
 
public without sharing class MyCandidateController {
   
   
    public Candidate__c c { get; set; }
    
    public MyCandidateController(){
        c=new Candidate__c();      
    }

    
    public MyCandidateController(ApexPages.StandardController con){
       c=new Candidate__c();
    
    }

    public PageReference save() {
       insert c;  
        PageReference pr=new PageReference('/apex/CandidateConfirmation');
        pr.setRedirect(true);
   
      return pr;
    }


   }





 
Hi guys,

Im having trouble getting my visualforce page to save data to my custom object. Im working in sandbox and using sites to expose my page publicly to get input from guest users. It works when I enter data from the preview but not when I open the link. I have checked my 'Public Access Settings' and gave the correct permissions for Org, Object and Field level security. I've tried everything from related posts but nothing seems to work.

Here is my code:

Visualforce page:
 
<apex:page standardStylesheets="false" sidebar="false" showHeader="false" standardController="Candidate__c" extensions="MyCandidateController">
<apex:form style="font:poppins;">
 
<apex:pageBlock >

        <center> <apex:image url="{!$Resource.Khono}" width="375" height="92"/> </center>
        <apex:styleSheet value="{!$Resource.Khonology_CSS_Style}"/>
        <apex:styleSheet value="{!$Resource.Khono_Font_Style}"/>
        <apex:styleSheet value="{!$Resource.Khono_Button_Style}"/>
        <apex:styleSheet value="{!$Resource.Khono_All_Min_Style}"/>


 <form id="contact-form">  
        <apex:pageBlockSection title="Personal Information">


            <apex:pageBlockSectionItem >
                
                <apex:inputfield html-placeholder="First Name" id="Name" value="{!c.Name}" />
            </apex:pageBlockSectionItem>
    
             <apex:pageBlockSectionItem >
                
                <apex:inputfield html-placeholder="Last Name" id="Surname" value="{!c.Surname__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
               <apex:outputLabel ><th><td>Gender</td></th></apex:outputLabel>
                <apex:inputField html-placeholder="Gender" id="Gender" value="{!c.Gender__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
                <apex:outputLabel ><th><td>Ethnicity</td></th></apex:outputLabel>
                <apex:inputField id="Ethnicity" value="{!c.Ethnicity__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
                <apex:outputLabel ><th><td>Country of Birth</td></th></apex:outputLabel>
                <apex:inputField id="COB" value="{!c.Country_of_Birth__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
               
                <apex:inputField html-placeholder="ID Number" id="IDno" value="{!c.ID_Number__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
                
                <apex:inputField html-placeholder="Email" id="Email" value="{!c.Email_Address__c}"/>
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
               
                <apex:inputField html-placeholder="Contact Number" id="ContactNo" value="{!c.Contact_Number__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
                <apex:outputLabel ><th><td>Residential Address Province</td></th></apex:outputLabel>
                <apex:inputField id="Province" value="{!c.Residential_Address_Province__c}" />
            </apex:pageBlockSectionItem>
    
</apex:pageBlockSection>

<apex:pageBlockSection title="Qualification">    

    
            <apex:pageBlockSectionItem >
                <apex:outputLabel >University</apex:outputLabel>
                <apex:inputField id="Uni" value="{!c.University__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Qualification</apex:outputLabel>
                <apex:inputField id="Qualification" value="{!c.Qualification__c}" />
            </apex:pageBlockSectionItem>
    
            <apex:pageBlockSectionItem >
                
                <apex:inputField html-placeholder="Major Subjects" id="Subjects" value="{!c.Major_Subjects__c}" />
            </apex:pageBlockSectionItem>
   
</apex:pageBlockSection>
 </form>    


    <apex:pageBlockButtons >    
        <apex:commandButton id="Save" action="{!Save}" value="Save" styleClass="btn .btn-primary"/>
        <apex:commandButton id="Cancel" action="{!Cancel}" value="Cancel" styleClass="btn .btn-primary"/>
    </apex:pageBlockButtons>



</apex:pageBlock>

    
</apex:form>
</apex:page>






Controller:
 
public without sharing class MyCandidateController {
   
   
    public Candidate__c c { get; set; }
    
    public MyCandidateController(){
        c=new Candidate__c();      
    }

    
    public MyCandidateController(ApexPages.StandardController con){
       c=new Candidate__c();
    
    }

    public PageReference save() {
       insert c;  
        PageReference pr=new PageReference('/apex/CandidateConfirmation');
        pr.setRedirect(true);
   
      return pr;
    }


   }