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
Vigneshwaran LoganathanVigneshwaran Loganathan 

Hi,

I am Creating records thru Visualforce page. Everytime I hit Save button only Id gets generated and Entered values are shown Blank.

VF
<apex:page standardController="Tandure_Domain__c" sidebar="false" extensions="attachementsample">
 <apex:form >
   <apex:pageblock >
   <apex:pageblockbuttons location="Bottom">
    <apex:commandButton value="Save" action="{!Save1}" disabled="{!save}"/>
   </apex:pageblockbuttons>
    <apex:pageblockSection title="Salesforce">  
       <apex:inputField value="{!Tandure_Domain__c.Name__c}"/>
       <apex:inputField value="{!Tandure_Domain__c.Education__c}"/>
    </apex:pageblockSection>
   </apex:pageblock>
  </apex:form>  
</apex:page>
Class
 
public class attachementsample {
public tandure_domain__c dom{get;set;}
String accid = System.currentPagereference().getParameters().get('id');

    public attachementsample(ApexPages.StandardController controller) {
    dom=new tandure_domain__c();
    }
   public void save1()
   {
     Database.upsert(dom); 
     system.debug('>>>>>'+dom); // Education and Name fields are Blank here, Only Id got generated
}
}


Thanks,
 
Best Answer chosen by Vigneshwaran Loganathan
PrakashbPrakashb
Hi,

You need to map your dom variable with the controller.

Please add the below assignment to your constructor.

dom = (tandure_domain__c)controller.getRecord();

This will map your page values to your class.

Regards,
Prakash B

All Answers

PrakashbPrakashb
Hi,

You need to map your dom variable with the controller.

Please add the below assignment to your constructor.

dom = (tandure_domain__c)controller.getRecord();

This will map your page values to your class.

Regards,
Prakash B
This was selected as the best answer
Vigneshwaran LoganathanVigneshwaran Loganathan
Thanks Praksh :)