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
GstartGstart 

How to get multiple records as input for a custom object in a single page?

I have created a page where I am getting input data for a custom object and saving it. As of now, I can save one record but I want to expand it to multiple records. How do I achieve it? The requirements are
i) User will be shown input fieds for first record when opening the page
ii) He can choose to add more rows to a max count of 20(Add rows by clicking "Add" button)
iii) Save all data once "Save" button is clicked
<tr>
                    	<td>
                            <apex:outputText value="First Name" styleClass="col-form-label"/>
                        </td>
                        <td>
                            <apex:inputText value="{!uAccount.First_Name__c}" html-placeholder="First Name" />
                        </td>
                        <td>
                            <apex:outputText value="Last Name" styleClass="col-form-label" />
                        </td>
                        <td>
                            <apex:inputText value="{!uAccount.Last_Name__c}" html-placeholder="Last Name" />                                          
                        </td>
                     </tr>

This is a sample code I have created to get first name and last name. This should be modified so that user can enter mutliple names if he want and save everything to the object. I have modified the object as a list object in apex class but do not know how to implement it in visualforce page
Maharajan CMaharajan C
Hi Gstart.

Refer the below Links it will surely helps to you friend!!!

Just change the fields and objects as per your need.

http://www.salesforcetutorial.com/visualforce-page-add-multiple-records/

https://salesforce.stackexchange.com/questions/94212/add-edit-multiple-records-on-custom-vf-page

Can you please Let me know if it works or not!!!

If it helps don't forget to mark this as a best answer!!!

Thanks,
​Raj