+ Start a Discussion
Alan ZieglerAlan Ziegler 

Newbie retrieving Lead record using name passed in URL

I am a newbie so any advice is most welcome as my whole approach may be wrong.  For a new web guest where I don't yet want to require the guest to reveal name and contact information, I have a page that creates a unique ID, saves this as a cookie, and uses web-to-lead to create a new Lead record with this name and his interests from a form multi-select list.  This all seems to work.  When this lead comes back in a new session, this page sees that he has a unique ID in cookie and assigns a new visualforce page with a URL parameter containing the existing unique ID.  The new page attempts to look up his Lead record interests using a controller extension with a select statement.  I have looked through many examples online of how to code the controller (some of which gave me syntax errors) and picked what seems like the simplest example for a template that "compiles".  From the start, the controller query is returning nothing.  So I have simplified the controller query to only try to find the first lead record to return and this also returns nothing.  My controller extension code is:

public class LeadNameLookupTest 
{
    public LeadNameLookupTest(ApexPages.StandardController controller) {}
    
    private Lead guest;
    public LeadNameLookupTest()
    {
         guest = [select ID, name from Lead limit 1];
    }
    public Lead getLeadRecord()
    {
        return guest;
     }
}

The visualforce page below third alert does display the unqiue ID being passed via URL but the earlier alerts display nothing in alert popup.  The  page code is:

<apex:page standardController="Lead" extensions="LeadNameLookupTest">
<script>
alert({!LeadRecord.ID});
alert({!LeadRecord.name});
var guest_name = "{!$CurrentPage.parameters.guest}";
alert(guest_name);
</script>
</apex:page>

Maybe the controller example I used is flawed.  I did see other more complicated templates. I even tried some of these more complicated examples but they would not "compile" or the page script reference to controller result failed.  Or maybe my alerts are a problem.
Best Answer chosen by Alan Ziegler
Alan ZieglerAlan Ziegler
Solution found through another discussion.  Please ignore this discussion.

All Answers

Scott Haleo 4Scott Haleo 4
Hi Alan,

Can you please share with me your complete issues & your requirement.

Regards,
Scott Haleo
Hytechpro
Alan ZieglerAlan Ziegler
Not sure what info you need.  To summarize my earlier long description, I am unsuccessful in creating a Lead controller extension that will retrieve a record using Lead name and display fields from the retrieved record in a visualforce page. Even when select statement only selects first Lead on file, the visualforce page display shows populated Lead fields as empty.
Alan ZieglerAlan Ziegler
Incidentally, I also tried using a form and input field to display the LeadRecord fields and it also displays fields as empty.
Alan ZieglerAlan Ziegler
Hmmm.  I commented out second line of controller extension code and referenced this as a custom controller in page.  Alerts stopped working but form input now displays the retrieved record fields.  So, I need to know how to convert this custom controller into a controller extension so I can also use the standard controller methods (rather than create references to all the standard controller methods in the custom controller).
Alan ZieglerAlan Ziegler
Solution found through another discussion.  Please ignore this discussion.
This was selected as the best answer