You need to sign in to do that
Don't have an account?

Extension to override New button
Hi ,
I've built the following extension to override new buttong for my Return Object.
<apex:page standardController="Return_Claim__c" extensions="returnExtension"> <apex:pageblock title="Return Claim Edit"> <apex:pageBlockButtons > <apex:form > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:form> </apex:pageBlockButtons> <apex:pageBlockSection title="Return Details" collapsible="false"> <apex:pageBlockSectionItem > <label><b><font face="arial" color="gray">Return Type</font></b></label> <apex:form > <apex:inputField required="true" value="{!Return_Claim__c.Return_Type__c}"/> </apex:form> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <label><b><font face="arial" color="gray">Serial Number</font></b></label> <apex:form > <apex:inputField required="true" value="{!Return_Claim__c.Serial_Number__c}"/> </apex:form> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageblock> </apex:page>
The extension is :
public class returnExtension { public ApexPages.StandardController con; public return_claim__c retn; public List<return_claim__c> result; public returnExtension(ApexPages.StandardController controller) { con = controller; retn=(return_claim__c)controller.getRecord(); } public PageReference save() { con.save(); // insert retn; return null; } }
Everything's working okay in the VF Page.
PROBLEM -- when I click on the save button; a record gets created but the values in the corrosponding fields do not get inserted.
PLEASE HELP ME OUT. I have tried almost all the dicussions board topics similar to this. nothing's helping.
Hey, the problem here is the too many form tags.
Each form data is treated individual for any action.
So, remove all the form tags and use only one form for entire page.
Finally, You dont need any extension for this functionality.
Your code should be turned out as followed .
All Answers
As you are using StandardController for the page, no need to specify the "Save" method in the controller part.
keep the entire logic same but remove the save method from the controller and try running the page.
You get the expected result.
Hi,
Thank for your respose.
I tried removing the SAVE method. No improvement ... still record's getting created but no data getting inserted
Your Apex code will be
public class returnExtension {
public ApexPages.StandardController con {get; set;}
public returnExtension(ApexPages.StandardController controller) {
con = controller;
}
public PageReference save()
{
return_claim__c retn = (return_claim__c)con.getRecord();
insert retn;
PageReference pageRef = new PageReference('/'+retn.Id);
pageRef.setRedirect(true);
return pageRef;
}
}
Hey, the problem here is the too many form tags.
Each form data is treated individual for any action.
So, remove all the form tags and use only one form for entire page.
Finally, You dont need any extension for this functionality.
Your code should be turned out as followed .
@Thiyagarajan
Still nothing ....
@Harsha,
Thanks a lot man .. that was great !! it works !!