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
meghana kollumeghana kollu 

form

Hi all
In the Registration form
if all the fields are filled then page should re direct to another page after that page details are entered in that page  then record should be inserted.

please helpme in detail
thanks in advance
Best Answer chosen by meghana kollu
NagendraNagendra (Salesforce Developers) 
Hi Meghana,

Please try the sample code below and tweak it as per the requirement.

Visual Force Page:
<apex:page sidebar="false" showHeader="false" standardController="Request__c" extensions="MyPageController">   
<apex:form >
    <apex:pageBlock >
    <apex:pageMessages />
    <apex:pageBlockSection >
    <apex:detail />
        <apex:inputField value="{! Request__c.First_Name__c}" />
        <apex:inputField value="{! Request__c.Last_Name__c}"/>
        <apex:inputField value="{! Request__c.Email_Address__c}"/>
        <apex:inputField value="{! Request__c.Cost_Center__c}"/>
        <apex:inputField value="{! Request__c.Department__c}"/>
        <apex:inputField value="{! Request__c.Director_s_Email__c}"/>
        <apex:inputField value="{! Request__c.Director_s_First_Name__c}"/>
        <apex:inputField value="{! Request__c.Director_s_Last_Name__c}"/>
        <apex:inputField value="{! Request__c.Mailstop__c}"/>
        <apex:inputField value="{! Request__c.Phone_Number__c}"/>

    </apex:pageBlockSection>
    </apex:PageBlock>       
        <apex:commandButton action="{! save}" value="Save"/>
       
    </apex:form>
</apex:page>
Controller Extension:
public class MyPageController {
Request__c request;
private ApexPages.StandardController controller;
public MyPageController(ApexPages.StandardController controller) {
this.controller = controller;
}
public PageReference saveAndCongrat() {
  controller.save(); // This takes care of the details for you.
  PageReference congratsPage = Page.Congratulations;
  congratsPage.setRedirect(true);
  return congratsPage;
}
Hope this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra