function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ch ranjeethch ranjeeth 

I want to insert records when the page is refreshed...i have written some code but its working with when i saving the page.Need help to wtire this code

<apex:page controller="Recordinsertion" action="{!method}">

</apex:page>

Controller:
public with sharing class Recordinsertion {

    public PageReference method()
     {
         list<account> acclist=new list<account>();
         for(integer i=50;i<51;i++)
         {
       
         account a=new account();
         a.name='acc'+i;
         acclist.add(a);
       }
     insert acclist;
      return null;
   }
}
Deepak Kumar ShyoranDeepak Kumar Shyoran
This will insert Account records every time when you reload this page. Are you facing any problem in this ?