+ Start a Discussion

After saving the field need to be empty

Hi all
I worked with save and new functionality.Whn i click save and new button the record get saved but the field doesn't get blank.
I need after i click save and new button,the record need to get saved and field need to blank. so we can enter another record.

This is my code
<apex:page standardController="Bank__c" extensions="custom">
<apex:form >
<apex:pageblock id="pb" >
<apex:pageblocktable value="{!Bank__c}" var="ban" >
<apex:column headerValue="ifsc code">
<apex:inputfield value="{!ban.IFSC_Code__c}"/>
<apex:commandButton action="{!savenew}" value="Save and New" rerender="pb"/>


public with sharing class custom {
public Bank__c ban { get; private set; }

private ApexPages.StandardController sController;  
    private String queryString;  
              public custom (ApexPages.StandardController controller) {  
        sController = controller;  
        ban = (Bank__c)controller.getRecord();  

 public Pagereference SaveNew()
   upsert ban;

   string s = '/' + ('' + ban.get('Id')).subString(0, 3) + '/e?';
   return new Pagereference(s);
What's wrong with my code.????
Record  get saved but field doesn't get blank
Best Answer chosen by Mubarak
Swayam  AroraSwayam Arora
Please change the SaveNew method as below

public Pagereference SaveNew()
   upsert ban;
   string s = '/' + ('' + ban.get('Id')).subString(0, 3) + '/e?';
   PageReference pg = new Pagereference(s);
   return pg;   

Please close the thread marking this answer as Best Answer if it really helped. Closing the thread help others finding the correct answer.