You need to sign in to do that
Don't have an account?
Vaibhav Desale
vf page help...unable to save record in backend
I am new to salesforce... please help... I have requirement like: one custom object Employee having three field Name,Account,Contact. Now I am creating a vf page with this three fields... but when I am saving my record from vf only employyee name is reflected. it is showing account and contact blank. And also i want to go redirect at record page which i am creating through vf when saved.
vf and controller as follows
vf
<apex:page StandardController="EmployeeA__c" extensions="classes" >
<apex:form >
<apex:pageBlock >
<apex:pageBlock title="Employee Page">
<apex:PageBlockSection >
<apex:inputText value="{!Name}"/>
<apex:inputField value="{!EmployeeA__c.Account__c}"/>
<apex:inputField value="{!EmployeeA__c.Contact__c}"/>
</apex:PageBlockSection>
<apex:pageBlockSection >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
</apex:page>
controller
public with sharing class classes {
public String Name { get; set; }
public String Account {get; set;}
public String Contact {get; set;}
VAD03__EmployeeA__c objdlt;
private ApexPages.StandardController controller;
public classes(ApexPages.StandardController controller) {
this.controller = controller;
}
public PageReference save() {
/*
VAD03__EmployeeA__c objdlt = new VAD03__EmployeeA__c();
objdlt.Name=Name;
objdlt.VAD03__Account__c=Account;
objdlt.VAD03__Contact__c=Contact;
insert objdlt;
*/
controller.cancel();
PageReference congratsPage = Page.Congratulations;
congratsPage.setredirect(true);
return congratsPage;
}
public PageReference Cancel() {
controller.cancel(); // This takes care of the details for you.
PageReference congratsPage = Page.Congratulations;
congratsPage.setRedirect(true);
return congratsPage;
}
}
vf and controller as follows
vf
<apex:page StandardController="EmployeeA__c" extensions="classes" >
<apex:form >
<apex:pageBlock >
<apex:pageBlock title="Employee Page">
<apex:PageBlockSection >
<apex:inputText value="{!Name}"/>
<apex:inputField value="{!EmployeeA__c.Account__c}"/>
<apex:inputField value="{!EmployeeA__c.Contact__c}"/>
</apex:PageBlockSection>
<apex:pageBlockSection >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
</apex:page>
controller
public with sharing class classes {
public String Name { get; set; }
public String Account {get; set;}
public String Contact {get; set;}
VAD03__EmployeeA__c objdlt;
private ApexPages.StandardController controller;
public classes(ApexPages.StandardController controller) {
this.controller = controller;
}
public PageReference save() {
/*
VAD03__EmployeeA__c objdlt = new VAD03__EmployeeA__c();
objdlt.Name=Name;
objdlt.VAD03__Account__c=Account;
objdlt.VAD03__Contact__c=Contact;
insert objdlt;
*/
controller.cancel();
PageReference congratsPage = Page.Congratulations;
congratsPage.setredirect(true);
return congratsPage;
}
public PageReference Cancel() {
controller.cancel(); // This takes care of the details for you.
PageReference congratsPage = Page.Congratulations;
congratsPage.setRedirect(true);
return congratsPage;
}
}
All Answers
Please mark as best answer if the above helps ..!!!
Thanks for reply....can u please tell me how to do this?