You need to sign in to do that
Don't have an account?
Mubarak
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:column>
</apex:pageblocktable>
</apex:pageblock>
<apex:commandButton action="{!savenew}" value="Save and New" rerender="pb"/>
</apex:form>
</apex:page>
===Controller===
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.????
note:
Record get saved but field doesn't get blank
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:column>
</apex:pageblocktable>
</apex:pageblock>
<apex:commandButton action="{!savenew}" value="Save and New" rerender="pb"/>
</apex:form>
</apex:page>
===Controller===
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.????
note:
Record get saved but field doesn't get blank
public Pagereference SaveNew()
{
upsert ban;
string s = '/' + ('' + ban.get('Id')).subString(0, 3) + '/e?';
PageReference pg = new Pagereference(s);
pg.setRedirect(true);
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.