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
Jasmeen Kaur 22Jasmeen Kaur 22 

Save Button is not working in VF Page

H Experts

I have created a VF page for my custom object (Forms). However when I hit save button it is not saving the record and brings the blank value in the field again. Can you please review my VF code below?

<apex:page standardController="Forms__c">
<apex:pageBlock title="Picking Slips and Sales Order" mode="inlineEdit">
<style>
.colStyle1 { width: 10%;padding-left:5px; text-align:left; padding-top:3px; padding-bottom:5px;}
.colStyle2 { width: 10%;text-align:left; padding-left:5px; padding-top:3px; padding-bottom:3px}
.colStyle3 { width: 10%; text-align:left;padding-left:5px; padding-right:10px; padding-top:3px; padding-bottom:3px}
.colStyle4 { width: 10%; text-align:left;padding-left:5px; padding-right:10px; padding-top:3px; padding-bottom:3px} 
.colStyle5 { width: 10%;padding-left:5px; text-align:left; padding-top:3px; padding-bottom:5px;}
.colStyle6 { width: 10%;text-align:left; padding-left:5px; padding-top:3px; padding-bottom:3px}
.colStyle7 { width: 10%; text-align:left;padding-left:5px; padding-right:10px; padding-top:3px; padding-bottom:3px}
.colStyle8 { width: 10%; text-align:left;padding-left:5px; padding-right:10px; padding-top:3px; padding-bottom:3px} 
.colStyle9 { width: 10%;padding-left:5px; text-align:left; padding-top:3px; padding-bottom:5px;}
.colStyle10 { width: 10%;text-align:left; padding-left:5px; padding-top:3px; padding-bottom:3px}
</style>
<apex:form >
  
  <apex:pageBlock title="Blum Hardware" mode="maindetail">
  <apex:panelGrid columns="10" border="0" styleClass="tableStyle" width="100%" columnClasses="colStyle1,colStyle2,colStyle3,colStyle4,colStyle5,colStyle6,colStyle7,colStyle8,colStyle9,colStyle10">
        <apex:outputLabel style="font-weight:600">Picking Slip 1</apex:outputLabel>  
        <apex:inputfield value="{!Forms__c.Picking_Slip_1_BH__c}"></apex:inputfield>
        <apex:outputLabel style="font-weight:600">Discount 1</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Discount_1_BH__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Sales Order 1</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Sales_Order_No_1_BH__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Order Date 1</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Order_Date_1_BH__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Invoice No.1</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Invoice_No_1_BH__c}"></apex:outputfield>
        
        <apex:outputLabel style="font-weight:600">Picking Slip 2</apex:outputLabel>  
        <apex:inputfield value="{!Forms__c.Picking_Slip_2_BH__c}"></apex:inputfield>
        <apex:outputLabel style="font-weight:600">Discount 2</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Discount_BH_2__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Sales Order 2</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Sales_Order_No_2_BH__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Order Date 2</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Order_Date_2_BH__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Invoice No.2</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Invoice_No_2_BH__c}"></apex:outputfield>
        
        <apex:outputLabel style="font-weight:600">Picking Slip 3</apex:outputLabel>  
        <apex:inputfield value="{!Forms__c.Picking_Slip_3_BH__c}"></apex:inputfield>
        <apex:outputLabel style="font-weight:600">Discount 3</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Discount_3_BH__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Sales Order 3</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Sales_Order_No_3_BH__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Order Date 3</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Order_Date_3_BH__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Invoice No.3</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Invoice_No_3_BH__c}"></apex:outputfield>
        
        
           
  </apex:panelGrid>
</apex:pageBlock>
</apex:form>

<apex:form >
  
  <apex:pageBlock title="Blum Servo Drive" mode="maindetail">
  <apex:panelGrid columns="10" border="0" styleClass="tableStyle" width="100%" columnClasses="colStyle1,colStyle2,colStyle3,colStyle4,colStyle5,colStyle6,colStyle7,colStyle8,colStyle9,colStyle10">
        <apex:outputLabel style="font-weight:600">Picking Slip 1</apex:outputLabel>  
        <apex:inputfield value="{!Forms__c.Picking_Slip_1_BSD__c}"></apex:inputfield>
        <apex:outputLabel style="font-weight:600">Discount 1</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Discount_1_BSD__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Sales Order 1</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Sales_Order_No_1_BSD__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Order Date 1</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Order_Date_1_BSD__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Invoice No.1</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Invoice_No_1_BSD__c}"></apex:outputfield>
        
        <apex:outputLabel style="font-weight:600">Picking Slip 2</apex:outputLabel>  
        <apex:inputfield value="{!Forms__c.Picking_Slip_2_BSD__c}"></apex:inputfield>
        <apex:outputLabel style="font-weight:600">Discount 2</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Discount_2_BSD__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Sales Order 2</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Sales_Order_No_2_BSD__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Order Date 2</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Order_Date_2_BSD__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Invoice No.2</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Invoice_No_2_BSD__c}"></apex:outputfield>
        
    
           
  </apex:panelGrid>
</apex:pageBlock>
</apex:form>
  
  <apex:form >
  
  <apex:pageBlock title="W & B" mode="maindetail">
  <apex:panelGrid columns="10" border="0" styleClass="tableStyle" width="100%" columnClasses="colStyle1,colStyle2,colStyle3,colStyle4,colStyle5,colStyle6,colStyle7,colStyle8,colStyle9,colStyle10">
       <apex:outputLabel style="font-weight:600">Picking Slip 1</apex:outputLabel>  
        <apex:inputfield value="{!Forms__c.Picking_Slip_1_WB__c}"></apex:inputfield>
        <apex:outputLabel style="font-weight:600">Discount 1</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Discount_1_WB__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Sales Order 1</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Sales_Order_No_1_WB__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Order Date 1</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Order_Date_1_WB__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Invoice No.1</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Invoice_No_1_WB__c}"></apex:outputfield>
        
        <apex:outputLabel style="font-weight:600">Picking Slip 2</apex:outputLabel>  
        <apex:inputfield value="{!Forms__c.Picking_Slip_2_WB__c}"></apex:inputfield>
        <apex:outputLabel style="font-weight:600">Discount 2</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Discount_2_WB__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Sales Order 2</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Sales_Order_No_2_WB__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Order Date 2</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Order_Date_2_WB__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Invoice No.2</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Invoice_No_2_WB__c}"></apex:outputfield>
        
        <apex:outputLabel style="font-weight:600">Picking Slip 3</apex:outputLabel>  
        <apex:inputfield value="{!Forms__c.Picking_Slip_3_WB__c}"></apex:inputfield>
        <apex:outputLabel style="font-weight:600">Discount 3</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Discount_3_WB__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Sales Order 3</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Sales_Order_No_3_WB__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Order Date 3</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Order_Date_3_WB__c}"></apex:outputfield>
        <apex:outputLabel style="font-weight:600">Invoice No.3</apex:outputLabel> 
        <apex:outputfield value="{!Forms__c.Invoice_No_3_WB__c}"></apex:outputfield> 
        
       
  </apex:panelGrid>
</apex:pageBlock>
</apex:form>

<apex:pageBlockButtons >
<apex:form >
  <apex:commandButton value="Save" action="{!Save}"/>
  <apex:commandButton value="Cancel" action="{!cancel}"/>
  </apex:form>
</apex:pageBlockButtons>
----
 </apex:pageBlock>
</apex:page>


Any help would be highly regarded.

Thanks in Advance

 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Jasmeen,

You can check by putting a system.debug and check if the values are correct and can you try making a alert statement to see if the button is working?

Regards,
Anutej
Alain CabonAlain Cabon
There is an error when you save (probably a validation rule or a missing mandatory field).

You can see the error messages with the tag: <apex:pageMessages />

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_std_validation_rules.htm
 
<apex:page standardController="Forms__c">
<apex:pageMessages />
<apex:pageBlock title="Picking Slips and Sales Order" mode="inlineEdit">