I am new to salesforce. My purpose is to display all the values of the selected checkboxes on one page, to the pther VF page. I studied that this can be done by getSelected() method. But I am unable to use it. Please can someone explain me with an example of VF page.

Is there any other method to achieve this goal?

  • 1
    Once you getSelected() you need to pass it to the controller to assemble a collection to send to the next page. The controller then creates a new pagereference passing the collection to the new page, especially when you're able to use the same controller. See the Visualforce Developer’s Guide and Visualforce in Practice.
    – crmprogdev
    Jul 22, 2015 at 13:15
  • Can you plese help me with an example, as I am new to programming
    – happy
    Jul 22, 2015 at 13:18
  • @crmprogdev How do you get the view PageReference from a StandardSetController? I only see cancel and save as returning a PageReference and it's just to the redirect or home page.
    – Adrian Larson
    Feb 1, 2016 at 18:07
  • @AdrianLarson. In the appendix of the VF Developer Guide you'll find the getSelected() method for standardSetControllers. It returns a list of the sObjects that have been selected.
    – crmprogdev
    Feb 4, 2016 at 17:13
  • @crmprogdev But that does not allow you to get some sort of redirect to a page using those records, which the OP seems to be looking for.
    – Adrian Larson
    Feb 4, 2016 at 17:20

1 Answer 1


In custom button you can write something like this:

    // Assuming you have standardcontroller for Case object
    var records = {!GETRECORDIDS($ObjectType.Case)};

    var updateRecords = [];

    if (records[0] == null) {
        alert("Please select at least one Case to update.");
    } else {
        window.location = 'apex/MyVisualforcePage?recs='+records.join(',');

After that you can get all selected record from the parameter named recslike that and do whatever you want:

List<String> caseIds = ApexPages.currentPage().getParameters().get('recs').split(',');
  • 1
    But where have you used "StandardSetController class" and getSelected method?
    – happy
    Jul 23, 2015 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.