+ Start a Discussion
JumboJumbo 

Create multiple records in a visual force page

Hi,

 

I wanna create a form who allows the creation of multiple records in one time, for example 10 opportunities or 10 contacts.

Best Answer chosen by Admin (Salesforce Developers) 
lvivaninlvivanin

Yes we can.

 

link

 

--lvivanin

All Answers

lvivaninlvivanin

Yes we can.

 

link

 

--lvivanin

This was selected as the best answer
JumboJumbo
Thank you lvivanin!
diya_sweet791.3326577046074976diya_sweet791.3326577046074976

<!-- visualforce page !-->

<apex:page controller="mypagecontroller">
<apex:form >
<apex:pageBlock >

<apex:pageblockbuttons >
<apex:commandButton action="{!saving}" value="save" />
</apex:pageblockbuttons>

<apex:repeat value="{!myrecords }" var="itr">
Name : <apex:inputField value="{!itr.Name}"/>
Select Age :<apex:inputField value="{!itr.Age__c}" /> <br/>
</apex:repeat>

</apex:pageBlock>
</apex:form>
</apex:page>

 

<!-- apex class !-->

public class mypagecontroller {

//attributes|properties
public list <volunteer__c> myrecords {get;set;}

 

//constructor
public mypagecontroller(){
myrecords =new list <volunteer__c> ();
myrecords.add(new volunteer__c());
myrecords.add(new volunteer__c());
myrecords.add(new volunteer__c());
myrecords.add(new volunteer__c());
myrecords.add(new volunteer__c());
}

//methods|functions

public void saving ()
{ insert myrecords ; }


}