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
venk1255venk1255 

How to display serial number in visual force page

 how to display serial numbers for records in visual force page can any one suggest me ,on this 

 

              Thanks in Adavance...

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard
There's a couple of options:

(1) Use the record id as the serial number
(2) Create an autonumber field on the record - you may need to update existing instances with this

All Answers

bob_buzzardbob_buzzard
What do you mean by a serial number? Is this a field on the record?
venk1255venk1255

Thanks for reply

 

 

i want display a serial number  for recrords in visual force page ,can u please provide any sample code for me 

 

 

           

bob_buzzardbob_buzzard

It depends on where this serial number comes from. Is it a field on your record, or are you looking to generate this from other data?

venk1255venk1255

i want to generate serial number  field on my records

bob_buzzardbob_buzzard
There's a couple of options:

(1) Use the record id as the serial number
(2) Create an autonumber field on the record - you may need to update existing instances with this
This was selected as the best answer
Prem ManickamPrem Manickam
Hi Venk,

Write a wrapper class set an integer property and use that wrapper class varible with your list of records. like below code

public class Wrapper{
        public CustomObj__c objCustom {get; set;}
        public Integer sNo {get; set;}
               
        public Wrapper(CustomObj__c objP){            
            this.objCustom = objP;          
            if(sNo==null){sNo=0;}  
            sNo++;                        
        }        
    }

use this sNo varible in the visualforce page the place where you want to display the serial number : in the repeat component

value = {!lstWrapper} var = "lstwrap"

<td>{!lstWrap.sNo}</td>

By
M.Prem