You need to sign in to do that
Don't have an account?
pdvapor
Custom List Controller not Filtering Account ID
I have created a custom object (Product_Sales__c) that is related to Accounts and when I try to create a custom list button on the related list to allow me to edit multiple records associated to an account, it brings back ALL Product Sales records when I am trying to filter by the current Account. How can I bring the current Account ID into my VFP to filter my list?
Class
public class UpdateProductSalesExt{ public List<Product_Sales__c> sales = new List<Product_Sales__c>([select id from product_sales__c where account__r.id = :ApexPages.currentPage().getParameters().get('id')]); public UpdateProductSalesExt(ApexPages.StandardSetController controller) { controller.setPageSize(100); } }
VFP
<apex:page standardController="Product_Sales__c" recordSetVar="sales" tabStyle="Product_Sales__c" extensions="UpdateProductSalesExt"> <apex:form > <apex:pageBlock title="Edit Product Sales" mode="edit"> <apex:pageMessages /> <apex:pageBlockButtons location="top"> <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!sales}" var="ps"> <apex:column value="{!ps.Account__c}"/> <apex:column value="{!ps.Product__r.Product_Category__c}"/> <apex:column value="{!ps.Product__c}"/> <apex:column headerValue="Total Wallet"> <apex:inputField value="{!ps.Total_Customer_Wallet__c}"/> </apex:column> <apex:column headerValue="Estimated Percentage of Total Wallet"> <apex:inputField value="{!ps.Estimated_Percentage_of_Wallet__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
This sounds like you'd be better off using a custom list controller. There's info and an example in the Visualforce Developer's Guide at:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_custom_list_controller.htm
Thanks Bob,
However, I now cannot seem to get my Custom List Button to direct it to my VF Page. In my above example I used it as an extension to the Standard Controller, but now am not able to reference it for the button. Here's my code.
Class
Page
Ah, okay. That won't quite fly, as you need the standard controller to be able to use it in that way.
However, I'd imagine you can do this in an extension controller and just build your own list of records rather than those exposed through the standard set controller.