0

I have a Master Object "Job Req", and a detail object "Application"

In a "Job Req" record, i need to put a button in "Applications" related list, that (for now) does something simple, like just open a VF page that displays the Applications that were selected in related list.

I will later expand on that myself. Right now i am having issue passing the selected records to the VF page.

This is what i have done -

Created a List button on Application object, that opens a VF Page

Added that Button to the Applications Related List on Job Req page layouts

Now When i select some records from Application Related List, and click on the button, i expect it to show names of just those applications. But somehow, it shows whole bunch of records. Instead of showing selected records, it shows some set of records that i don't even know

Selecting singel record

Here is the output, which shows some bunch of records, instead of showing just 1 i selected- Output shows some set of records here

Here is my VF page code

<apex:page standardController="ts2__Application__c" recordSetVar="selectedApplications">
  <apex:pageBlock >
    <apex:pageBlockTable value="{!selectedApplications}" var="a">
        <apex:column value="{!a.name}"/>       
    </apex:pageBlockTable>
  </apex:pageBlock>
</apex:page>

If anyone has any clue how to get selected records working from a related list, please let me know (using Standard set controllers). I don't want to use a javascript button that passes IDs of selected records. I already have that working, but it has limitations on how many IDs can be passed via URL parameter (most browsers crap at url length of 2000 characters).

0

You can use controller extension with StandardSetController. The getSelected() method of StandardSetController returns the selected records.

Visualforce

<apex:page standardController="ts2__Application__c" recordSetVar="selectedApplications" extensions="ApplicationExtn">
  <apex:pageBlock >
    <apex:pageBlockTable value="{!selectedApplications}" var="a">
        <apex:column value="{!a.name}"/>       
    </apex:pageBlockTable>
  </apex:pageBlock>
</apex:page>

Controller Extension

public class ApplicationExtn {
    public List<ts2__Application__c> selectedApplications {get;set;}
    private ApexPages.StandardSetController controller;
    private Set<Id> appIds = new Set<Id>();

    public ApplicationExtn(ApexPages.StandardSetController controller){
        this.controller = controller;
        selectedApplications = controller.getSelected();
}

For more information, refer StandardSetController Class

  • Thanks a lot man. I tried using getselected in a separate method, not in constructor. Then called it on the page in pageBlockTable, and it wasnt working. But your advice worked perfectly – user41343 Jan 31 '17 at 17:22
  • I also observed a weird limit here. From the related list, i selected over 100 applications, but my VF page only showed 100 applications. I used another implementation, where a javascript button gets IDs of selected applications and pass them as parameter to VF page. Even there i noticed this limit of 100 records. It crops down the number of records to 100. Just FYI to anyone reading this. – user41343 Jan 31 '17 at 19:15
  • can you try setting setPageSize(200) and do a testing. I think default is 100 records – Santanu Boral Jan 31 '17 at 20:02

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.