You need to sign in to do that
Don't have an account?
sfdc_syed
How do i insert a record using visual force page?
Hi All,
I have a senario like i have single field in vf and when we run a visulforce page then record has to insert automatically without clicking any buttons .so how can i do that so kindly let me know with example.
Thanks
Hi Navatar,
Its working Thanks alot !
All Answers
Hi,
You can write a method in your controller that insert your record and call that method on action attribute of as
<apex:page action="{!your controller method}"> tag.
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi navatar,
As shown below whether it is write of wrong ?.if there is any changes kindly change it do let me know.
public class Tcontroller
{
public pageReference dest()
{
Account newAcct = new Account(name = 'Acme');
try {
insert newAcct;
} catch (DmlException e) {
// Process exception here
}
}
<apex:page controller="Tcontroller" >
<apex:form >
<apex:page action="{!dest()}">
</apex:form>
</apex:page>
Thanks
Hi,
This is your modified code.You can use it and get record inserted automaitcally
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Hi Navatar,
Its working Thanks alot !