You need to sign in to do that
Don't have an account?
Shivam Dash
how to save the recod and redirect to another vf page when click on save button
Hi i want to save the record and redirect to another vf page when clcik on save button . i am able to redirect to vf page but its not saving the record . i am posting the code please anyonre help me out what i am missing .
<apex:page standardController="Account" recordSetVar="Accounts" id="thePage" showHeader="true" sidebar="false" extensions="extension1" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!Accounts}" var="Acc">
<apex:column value="{!Acc.name}"/>
<apex:column headerValue="Account Number">
<apex:inputField value="{!Acc.AccountNumber}"/>
</apex:column>
<apex:column headerValue="Phone">
<apex:inputField value="{!Acc.Phone}"/>
</apex:column>
</apex:pageBlockTable>
<apex:inlineEditSupport />
<apex:pageBlockButtons >
<apex:commandButton value="Next" action="{!Next}" id="saveButton" reRender="none" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
----------------------------------------------------
public class extension4 {
private ApexPages.StandardController controller;
public extension4 (ApexPages.StandardSetController controller) {
}
public PageReference Next(){
controller.save();
PageReference reRend = new PageReference('/apex/mypage22');
return reRend;
}
}
<apex:page standardController="Account" recordSetVar="Accounts" id="thePage" showHeader="true" sidebar="false" extensions="extension1" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!Accounts}" var="Acc">
<apex:column value="{!Acc.name}"/>
<apex:column headerValue="Account Number">
<apex:inputField value="{!Acc.AccountNumber}"/>
</apex:column>
<apex:column headerValue="Phone">
<apex:inputField value="{!Acc.Phone}"/>
</apex:column>
</apex:pageBlockTable>
<apex:inlineEditSupport />
<apex:pageBlockButtons >
<apex:commandButton value="Next" action="{!Next}" id="saveButton" reRender="none" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
----------------------------------------------------
public class extension4 {
private ApexPages.StandardController controller;
public extension4 (ApexPages.StandardSetController controller) {
}
public PageReference Next(){
controller.save();
PageReference reRend = new PageReference('/apex/mypage22');
return reRend;
}
}
Modify the type of variable "controller" and constructor. This makes the variable controller have standard controller and then record can be saved in your method.
And perhaps extension4 is typo of extension1? (it's inconsistent with apex:page tag)
I tried this one but not getting save the record .
miss printed of that extension 4 instead of extension 1 .
It's weird.. I will provide a sample DE org that implements above code soon!
Sorry for late. Had some trouble logging in this forum. Try below env.
ID : shivam.dash@de.test
Pass : S@lesforce1
I created /apex/TestAccountList and dummy mypage22.