+ Start a Discussion
Sainath VenkatSainath Venkat 

Visualforce page to show created records one by one

Is it possible to create and show created record in vf page one by one.

I have one VF Page which is having Input Field Barcode__c which is text, the moment I click save it creates record which is working perfectly.

Now I want to reset the input field to enter data to create another record but VF Page should have table below to show created records.

Can anyone help me out in this issue
<apex:page standardController="Staging_Event_Attendee__c" lightningStylesheets="true" >
                <apex:inputField value="{!Staging_Event_Attendee__c.Barcode__c }"/>
            <apex:pageblockButtons >
               <apex:commandButton value="save" action="{!save}"/>

Deepali KulshresthaDeepali Kulshrestha
Hi Sainath,
Please follow the given below Code with the help of code you can solve your problem, it may be helpful to you.

Please change the Name of the Object according to your requirement, I have used Account object in below code.
VF page code :
<apex:page Controller="InsertAndShowData">
        <apex:pageBlock title="New Account">
            <apex:pageBlockSection id="reRenderId">
                <apex:inputText value="{!Name}"/>
                <apex:commandButton value="Insert" onclick="alrt()" action="{!save}" reRender="reRenderId" oncomplete="refreshPage();"/>
            <apex:pageBlockTable value="{!accList}" var="a" rows="1000">
                <apex:column headerValue="Account Name" value="{!a.Name}"/>
        function alrt(){

            alert('Do you really want to insert record?');

Apex Controller :

public class InsertAndShowData {
    public String Name{get;set;}
    public List<Account> accList {get;set;}

    public InsertAndShowData(){
        accList=[SELECT Name FROM Account Name ORDER BY Name ASC LIMIT 100];

    public PageReference save() {
        Account ac = new Account();
        ac.Name = Name;
        insert ac;
        this.Name = null;
        return null;
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha