• I am AB
  • NEWBIE
  • 15 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Visualfrom Page( StudentApp)
<apex:page StandardController="StudentApp__c" extensions="StudentRecord">
  <apex:form >
        <apex:pageBlock title="Student New Record">
              <apex:pageBlockSection title="Student New Record" >
                    
                    <apex:outputLabel value="Phone"></apex:outputLabel>
                    <apex:inputText value="{!StPhone}"/>
                    <apex:outputLabel value="Email"></apex:outputLabel>
                    <apex:inputText value="{!StEmail}" /> 
                    <apex:outputLabel value="Student Name"></apex:outputLabel>
                    <apex:inputText value="{!StName}" />                
              </apex:pageBlockSection>
              <apex:pageBlockButtons >
                <apex:commandButton action="{!insertStudent}" value="{!$Label.SaveStudent}" />
                <apex:commandButton action="{!insertAndNew}" value="Save and New" />
                <apex:commandButton action="{!cancel}" value="Cancel" /> 
              </apex:pageBlockButtons>
         </apex:pageBlock>
    </apex:form> 
</apex:page>
VisualForce Page(ViewStudent)
<apex:page StandardController="StudentApp__c" extensions="StudentRecord" action="{!getStudentInfo}">
  <apex:form >
        <apex:pageBlock title="Student View Record">
              <apex:pageBlockSection title="Student View Record" >
                    
                    <apex:outputLabel value="Phone"></apex:outputLabel>
                    <apex:outputText value="{!StPhone}"/>
                    <apex:outputLabel value="Email"></apex:outputLabel>
                    <apex:outputText value="{!StEmail}" /> 
                    <apex:outputLabel value="Student Name"></apex:outputLabel>
                    <apex:outputText value="{!StName}" />                
              </apex:pageBlockSection>
              
              <apex:pageBlockButtons location="Top">
             <apex:commandButton value="Edit" action="{!UpdateStudent}"/>
         </apex:pageBlockButtons>
              
         </apex:pageBlock>
         
    </apex:form> 
</apex:page>

Controller (StudentRecord )
 
public class StudentRecord {

    public string StName{get;set;}
    public string StEmail{get;set;}
    public String StPhone{get; set;}
    
    public StudentRecord(ApexPages.StandardController controller) {
            }
    
    public StudentRecord(){
    }
    public PageReference insertStudent(){
        
        StudentApp__c st= new StudentApp__c();
        
        st.Name=StName;
        st.StudentEmail__c=StEmail;
        st.StudentPhone__c=StPhone;
        
        insert st;
        
        //StudentApp__c st = [select Id from StudentApp__c where Id = :st.id];
        
        PageReference stPage = new PageReference(Page.studentview.getUrl()+'?Id='+st.Id);
        stPage.setRedirect(true);
        return stPage;
    } 
    
    public PageReference insertAndNew(){
        
        StudentApp__c st= new StudentApp__c();
        
        st.Name=StName;
        st.StudentEmail__c=StEmail;
        st.StudentPhone__c=StPhone;
        
        insert st;
        
        PageReference stPage = new PageReference(Page.studentapp.getUrl());
        stPage.setRedirect(true);
        return stPage;
    }
    
    public void getStudentInfo()
    {
        String id = ApexPages.currentPage().getParameters().get('Id');
        if(id != null)
        {
            StudentApp__c st = [select Id, Name, StudentEmail__c, StudentPhone__c from StudentApp__c where Id = :id];
            stName = st.name;
            StEmail = st.StudentEmail__c;
            StPhone = st.StudentPhone__c;
        }}
                
      public PageReference UpdateStudent(){
                String id = ApexPages.currentPage().getParameters().get('Id');
                if(id != null){
                        StudentApp__c st = [select Id, Name, StudentEmail__c, StudentPhone__c from StudentApp__c where Id = :id];
                                            
                        //System.debug(st.StudentEmail__c);
                        StName=st.Name;
                        StEmail=st.StudentEmail__c;
                        StPhone=st.StudentPhone__c;
                        
                        update st;
                   
                       PageReference vin = new PageReference(Page.studentapp.getUrl()+'?Id='+st.Id);
                       vin.setRedirect(true);
                       return vin;}
                       
                       else{
                             return null;
                            }
                    
        }
    
}

When i am firing an action update button (Edit ), It is successfully redirected to the edit page which is studentapp vf page. But the field is this form are blank. I need them to be filled with the values of the record which is iam passing through the id. 
Please help!
Thanks in advance!
 
Hi Expert, 
I am very new the salesforce.
I want to insert a records in my custom object Invoice__c, But nothing is inserted with this code.
 
VF page code:

<apex:page standardController="Invoice__c" extensions="particular" docType="Html-5.0" sidebar="false" tabStyle="invoice__tab">
  <apex:form >
      
<apex:pageBlock title="Invoice Details" >
     
 <apex:pageBlockSection title="Account Details" columns="1">
          <apex:inputfield Value="{!Invoice__c.Account_Name__c}"/>
      </apex:pageBlockSection> 
     
 <apex:pageBlockSection title="Invoice Details" columns="2">   
          <apex:inputField Value="{!Invoice__c.Invoice_Date__c}"/>
          <apex:inputField value="{!Invoice__c.Description__c}"/>
          <apex:inputField value="{!Invoice__c.Net_Total__c}"/>
      </apex:pageBlockSection>

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

Controller Code:

Controller Page

public class particular {
    
    public invoice__c invoices;
    public account accountname {get;set;}
    public datetime indate {get;set;}
    public string des {get;set;}
    public decimal nettotal {get;set;}
 
 
    public particular(ApexPages.StandardController controller) { 
    }
    
       public PageReference save(){

         invoice__c objin = new invoice__c();

         objin.Account_Name__r= accountname; 
         objin.Description__c= des; 
         objin.invoice_Date__c=indate;
         insert objin;

         PageReference vin = new PageReference(Page.ViewInvoice.getUrl()+'?Id='+objin.Id);
         vin.setRedirect(true);
         return vin;
 
    }       

     
     public Pagereference cancel(){
            
        PageReference Pg= Page.NewInvoice;
        pg.setRedirect(true);
        return Pg;  
     }
 
}

Thanks in advance
Sherry ! 
Hi Expert, 
I am very new the salesforce.
I want to insert a records in my custom object Invoice__c, But nothing is inserted with this code.
 
VF page code:

<apex:page standardController="Invoice__c" extensions="particular" docType="Html-5.0" sidebar="false" tabStyle="invoice__tab">
  <apex:form >
      
<apex:pageBlock title="Invoice Details" >
     
 <apex:pageBlockSection title="Account Details" columns="1">
          <apex:inputfield Value="{!Invoice__c.Account_Name__c}"/>
      </apex:pageBlockSection> 
     
 <apex:pageBlockSection title="Invoice Details" columns="2">   
          <apex:inputField Value="{!Invoice__c.Invoice_Date__c}"/>
          <apex:inputField value="{!Invoice__c.Description__c}"/>
          <apex:inputField value="{!Invoice__c.Net_Total__c}"/>
      </apex:pageBlockSection>

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

Controller Code:

Controller Page

public class particular {
    
    public invoice__c invoices;
    public account accountname {get;set;}
    public datetime indate {get;set;}
    public string des {get;set;}
    public decimal nettotal {get;set;}
 
 
    public particular(ApexPages.StandardController controller) { 
    }
    
       public PageReference save(){

         invoice__c objin = new invoice__c();

         objin.Account_Name__r= accountname; 
         objin.Description__c= des; 
         objin.invoice_Date__c=indate;
         insert objin;

         PageReference vin = new PageReference(Page.ViewInvoice.getUrl()+'?Id='+objin.Id);
         vin.setRedirect(true);
         return vin;
 
    }       

     
     public Pagereference cancel(){
            
        PageReference Pg= Page.NewInvoice;
        pg.setRedirect(true);
        return Pg;  
     }
 
}

Thanks in advance
Sherry ! 

Hi all ,

          I want to know what is the exact difference between salesforce.com and Force.com ,

          Can any one help me to know about that?