You need to sign in to do that
Don't have an account?
DevSF
Perform Multiple Actions On Save Button Click In Visualforce Page
Hi Friends,
I am Updating a record using Visualforce page. When I enter all the data into visualforce page, Here i need to perform 2 actions.
1) Save the record
2) Open a link
I tried it using page reference(), but struck at some point.
<apex:commandButton value="Save" action="{!Save}" />
Controller ::
public class rerender {
public Account acc {get;set;}
public rerender(ApexPages.StandardController controller) {
}
public PageReference save(){
PageReference reRend = new PageReference('/apex/ThankYou');
reRend.setRedirect(false);
return reRend;
}
}
In this, i was unable to save the record, but was able to open the link.
How to achieve this...!
I am Updating a record using Visualforce page. When I enter all the data into visualforce page, Here i need to perform 2 actions.
1) Save the record
2) Open a link
I tried it using page reference(), but struck at some point.
<apex:commandButton value="Save" action="{!Save}" />
Controller ::
public class rerender {
public Account acc {get;set;}
public rerender(ApexPages.StandardController controller) {
}
public PageReference save(){
PageReference reRend = new PageReference('/apex/ThankYou');
reRend.setRedirect(false);
return reRend;
}
}
In this, i was unable to save the record, but was able to open the link.
How to achieve this...!
public class rerender {
public Account acc {get;set;}
public rerender(ApexPages.StandardController controller) {
acc = (Account)stdController.getRecord();
}
public PageReference save(){
update acc;
PageReference reRend = new PageReference('/apex/ThankYou');
reRend.setRedirect(false);
return reRend;
}
}
Yes we can create a custom button which can perform multiple action. I just tested it in dev console.
You are missing the DML statement here in the save method.Use Insert,Update or (insert and update both ) based on your requirement.
Please comment if you find this helpful.Thanks!!!.