+ Start a Discussion
sfdc freshersfdc fresher 

how to insert a record when the vf page is loaded

hi everyone,
could anyone please explain me how to perform actions like(insert,update etc) when the vf page is loaded.



Thanks
Om PrakashOm Prakash
You can do by using action attribute of apex:page 
Write your logic in method doAction. 
<apex:page action="{!doAction}" controller="ControllerName">
Note - If you are working for app then this is not recommneded in term of security.

DML can be also perform by using JS remoting when page is loaded or you can also call a method by using actionFunction from java script while page is loaded.