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
RetreeverRetreever 

First VF Page

So I am starting to work with VF pages. My first goal is to have a VF form that would allow me to create new records in a custom object either from inside Salesforce or from a outside webpage using sites. With some help I have been able to create the form (see attached code and screen cap). But when I populate the form and hit save it doesn't seem to do anything, so I guess I've missed something or there's something wrong with my code. I would appreciate any suggestions and how to fix this.
 
<apex:page standardController="Loyalty_Program_Member__c">
    <apex:form id="changeStatusForm">
        <apex:pageBlock >
          <apex:pageblocksection title="Loyalty Program Member Detail">
               <apex:inputfield value="{!Loyalty_Program_Member__c.First_Name__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Last_Name__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Full_Name__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Street_Address__c}"/>
        <apex:inputfield value="{!Loyalty_Program_Member__c.City__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Province_State__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Country__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Postal_Zip__c}"/>
        <apex:inputfield value="{!Loyalty_Program_Member__c.Home_Phone__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Mobile__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Email__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Type_of_Pet__c}"/>
        <apex:inputfield value="{!Loyalty_Program_Member__c.Product_Purchased__c}"/>
        </apex:pageblocksection>
        <apex:pageblocksection title="Retailer Information">
             <apex:inputfield value="{!Loyalty_Program_Member__c.Retailer_Name__c}"/>
             <apex:inputfield value="{!Loyalty_Program_Member__c.Retailer_Address_Street__c}"/>
        <apex:inputfield value="{!Loyalty_Program_Member__c.Retailer_Address_City__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Retailer_Address_State_Province__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Retailer_Address_Country__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Retailer_Address_Postal_Zip__c}"/>
        <apex:inputfield value="{!Loyalty_Program_Member__c.Retailer_Phone__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Retailer_Fax__c}"/>
               <apex:inputfield value="{!Loyalty_Program_Member__c.Retailer_Email__c}"/>
        </apex:pageblocksection>
        <apex:pageBlockButtons >
             <apex:commandButton value="Save" action="{!save}"/>
        </apex:pageBlockButtons>
       </apex:pageBlock>
    </apex:form>
</apex:page>
User-added image
 
Best Answer chosen by Retreever
William TranWilliam Tran
You likely have an error,  add <apex:messages /> to see the error message and proceed from there:

Add <apex:messages /> right below the <Apex:page.....> like:

<apex:page standardController="Loyalty_Program_Member__c">
<apex:messages />

As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

Thanks
 

All Answers

pconpcon
Do you see any errors on the page?  What actually happens when you click on save? If you look at the debug logs for you user when you submit it, do you see any errors?
William TranWilliam Tran
You likely have an error,  add <apex:messages /> to see the error message and proceed from there:

Add <apex:messages /> right below the <Apex:page.....> like:

<apex:page standardController="Loyalty_Program_Member__c">
<apex:messages />

As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.

Thanks
 
This was selected as the best answer
RetreeverRetreever
Thanks both of you , you got me thinking in the right direction - William I added the "messages" coding per your suggestion and I was able to fix the problem right away - there was a required field for the new record which I had not included in my code.
RetreeverRetreever
Ok, so I have successfully got the VF Form to show on my Force.com site , anyone can go to the URL and see the form , even fill it in but when you hit Save I get the following "Error Message: Authorization Required-You must first log in or register before accessing this page.If you have forgotten your password, click Forgot Password to reset it."

I have confirmed the permissions are set properly on the Custom Object and in the OWD settings , I think it's something to do with using "standardController" maybe I need a custom controller to make this work - anyone have any suggestions? Thanks, Roger