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
ravi1234.ax1565ravi1234.ax1565 

display selected records in visualforce page

Hello Group ,

 

                         I wanna display selected records in vf page by clicking custom button in page layout.  To achieve this i created a custom button in page layout and a visualforce page(standard controller) but iam getting   

all records in vf page when i click on a custom button in page layout.

 

 Note : when i click that custom button it displays a vf page with all records but i want only selected records 

 

     pls help me to achieve this 

 

   thanks fopr giving reply (in advance)

Best Answer chosen by Admin (Salesforce Developers) 
hitesh90hitesh90

Hi ravi,

 

see below controller example for contact Object. Here in lstContact you will get selected contact records.

You have to take Your sObject name instead of Contact.

 

Apex Class:

public class ctrlSelectedListContact{	
	public List<Contact> lstContact {get; set;}		
	public ctrlSelectedListContact(ApexPages.StandardSetController controller){		
		lstContact = (List<Contact>)controller.getSelected();		
	}	
}

 

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator

All Answers

hitesh90hitesh90

hi ravi,

 

Which type of button you have created? List Button or Detail Page Button?

 

Thank You,

Hitesh Patel

ravi1234.ax1565ravi1234.ax1565

Thanks for giving reply 

 

 

    Button type is list button

 

        thanks and regards 

hitesh90hitesh90

Hi ravi,

 

see below controller example for contact Object. Here in lstContact you will get selected contact records.

You have to take Your sObject name instead of Contact.

 

Apex Class:

public class ctrlSelectedListContact{	
	public List<Contact> lstContact {get; set;}		
	public ctrlSelectedListContact(ApexPages.StandardSetController controller){		
		lstContact = (List<Contact>)controller.getSelected();		
	}	
}

 

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator

This was selected as the best answer
ravi1234.ax1565ravi1234.ax1565

haaaaaaaaaaaaa   it is working

 

 

 

      thanq hitesh 

 

 

  thanks for giving reply

shankar.04261.391512445023714E12shankar.04261.391512445023714E12
Hi,
 can i have the visual force code and apex code meanwhile for displaying selected records in seperate page..?
  

Regards,
 Siva