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
Pat WimsattPat Wimsatt 

Return a list on visual force page

Our Sales team has a custom Object called Lane Details.  On the page layout for this object I created a custom button to open a Visualforce page.  That vf page has a controller that goes out and pulls records to display in a list form. That list needs a parameter from the Lane Details page.  I can't seem to pass the parameter from the 1st page to the Controller so that it returns the selected criteria.  I have tried both of these... where origin_city__c is the custom field that the controller needs to use to pull the correct records.  

System.currentPageReference().getParameters().get('origin_city__c');
Apex.currentPage().getParameters().get('origin_city__c');

Here is the controller:

public class LaneDetailCon {
 
    static List<Lane_Detail__c> lanes;
 
    public static List<Lane_Detail__c> getLanes() {
        
            String ocity  = System.currentPageReference().getParameters().get('origin_city__c');
            System.debug(ocity);
       
            lanes = [SELECT id, Origin_City__c, Origin_Statess__c, Destination_City__c,
                     Destination_States__c, Rate__c FROM Lane_Detail__c 
                     WHERE Origin_City__c = :ocity
                     LIMIT 25];
        return lanes;
    }
 }


I do NOT need an inputField or inputText in my output.  The user will not be editting nor entering data. They just need to see a list of the records based on the query in the controller.
In the above example, the variable ocity returns null because by then the second page has rendered and the field no longer exists.

I hope this makes sense. I really need to get this working. Thank you. 


 
ANUTEJANUTEJ (Salesforce Developers) 
Hi Pat,

>> https://salesforce.stackexchange.com/questions/101536/how-do-i-persistent-data-between-vf-pages-that-change-the-view-state-that-shar

I found this link that mentions a way to make data persistent through multiple visualforce pages.

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.
RituSharmaRituSharma
I could not understand your below mentioned statement:

I can't seem to pass the parameter from the 1st page to the Controller so that it returns the selected criteria.

I can see that your are reading origin_city__c from URL using System.currentPageReference().getParameters().get('origin_city__c'). Now my question is, how and from where you are passing this parameter?