[Salesforce] - Create record for different objects from same Page Layout 




Code for Visualforce page - 
<apex:page controller="StudTeachUpdate">
<apex:form >
<apex:pageblock >
<apex:pageblockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageblockButtons>
<apex:pageblockSection title="Student">
<apex:inputField value="{!stud.Student_Name__c}"/>
<apex:inputField value="{!stud.Email_Id__c}"/>
<apex:inputField value="{!stud.Country__c}"/>

</apex:pageblockSection>

<apex:pageblockSection title="Professor">
<apex:inputField value="{!prof.Name}"/>
<apex:inputfield value="{!prof.Email_id__c}"/>
</apex:pageblockSection>

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


Code for Controller - 
public class StudTeachUpdate {

public Student__c stud{get;set;}
public Professor__c prof{get;set;}

    public StudTeachUpdate ()
    {
        stud= new Student__c ();
        prof = new Professor__c();

    }
public pagereference save()
{
insert stud;
insert prof;

return null;
}

}
[Salesforce] - A Simple Visualforce Code to create a Pdf of a record
Code -

<apex:page StandardController="Account" renderAs="PDF">
  <apex:pageBlock >
  <apex:pageBlockTable value="{!Account.Contacts}" var="Con" style="border:1px solid;" cellpadding="6px">

  <apex:column headerValue="Name">
  {!Con.name}
  </apex:column>

  <apex:column headerValue="Title">
  {!Con.Title}
  </apex:column>

  <apex:column headerValue="Email">
  {!Con.email}
  </apex:column>

  </apex:pageBlockTable>
  </apex:pageBlock>
</apex:page>

Creating a Simple Visualforce Page - For Beginners

Creating a Simple Visualforce Page - For Beginners





Code - 

<apex:page standardController="Student_new__c">
  <apex:sectionheader title="Student"/>
  <apex:form >
  <apex:PageBlock title="Input"> 
  <apex:PageBlockButtons >
  <apex:commandButton value="Save" action="{!Save}"/>
  </apex:PageBlockButtons>
  <apex:pageblockSection >
  
  <apex:inputField value="{!Student_new__c.Name}"/>
  <apex:inputField value="{!Student_new__c.class__c}"/>
   <apex:inputField value="{!Student_new__c.Class_Monitor__c}"/>
   <apex:inputField value="{!Student_new__c.Teacher_Name__c}"/>
   
  </apex:pageblockSection>
  </apex:PageBlock>
  
  </apex:form>
  <apex:form >
  <apex:PageBlock title="output"> 
  <apex:pageblockSection >
  <apex:outputField value="{!Student_new__c.class__c}"/>
   <apex:outputField value="{!Student_new__c.Class_Monitor__c}"/>
   <apex:outputField value="{!Student_new__c.Teacher_Name__c}"/>
   
  </apex:pageblockSection>
  </apex:PageBlock>
  
  </apex:form>
  

</apex:page>