I have a List Button on a custom object. I need to use that button in that object as detail page button. Please find the VF page that List button calls here.


<apex:page standardController="Compliance_Incident_abv__c" recordSetVar="Incidents" extensions="CompIncidentListActionController" tabStyle="Compliance_Incident_abv__c">
    <apex:form >
        <apex:pageBlock title="Selected Incidents to Publish" id="Pb1">
            <apex:pageMessages />

            <apex:pageBlockTable value="{!selected}" var="inc"  rendered="{!SelectedSize > 0}">
                <apex:column value="{!inc.name}"/>
                <apex:column value="{!inc.Rep_abv__c}"/>                
                <apex:column value="{!inc.OwnerId}"/>
                <apex:column value="{!inc.CreatedDate}"/>                                
                <apex:column value="{!inc.Publish_Date_abv__c}"/>                 
                <apex:column value="{!inc.No_Of_Transactions_abv__c}"/> 
                <apex:column value="{!inc.Status_abv__c}"/>                               
            <apex:pageBlockButtons >
                    <apex:commandButton value="Confirm" action="{!Publish}"  rendered="{!SelectedSize > 0}"/>
                    <apex:commandButton value="Back" action="{!cancel}"/>                    

I thought you might have been able to use it for both in spite of the use of recordSetVar but I guess not. I think the solution here will be to create an 'in the middle' Visualforce page that uses the Compliance_Incident_abv__c standard controller, and as part of an init action simply redirects to the existing page passing a single Id.

So the page would look something like:

<apex:page standardController="Compliance_Incident_abv__c" extensions="CompIncidentDetailActionController" tabStyle="Compliance_Incident_abv__c" action="{!doForward"}">

With the new extension controller looking something like this:

public with sharing class CompIncidentDetailActionController
  private Id recordId;

  public CompIncidentDetailActionController(ApexPages.StandardController sc)
    recordId = sc.getRecord().Id;

  public PageReference doForward()
    // Use the old page name here
    ApexPages.PageReference pr = Page.ExistingPage;
    pr.getParameters().put('Ids', recordId);
    return pr; 

Note This code is completely untested and has been written straight in the browser, so a few method names could be wrong, but it demonstrates the technique at any rate.

  • Can you please let me know what should be the page? Getting a bit confused! – user59759 Mar 11 '15 at 4:50
  • Sorry for the delay, expanded the answer which should get you going! – Matt Lacey Mar 13 '15 at 23:28

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.