+ Start a Discussion
Troy SearcyTroy Searcy 

Auto-fill lead fields on visualforce page

I have a basic VF page that acts as a lead submission form. After users enter the customer info, they click a "Save" button and then a "New Lead" button. 

I would like the "New Lead" button to bring the user back to the same VF page, but auto-fill in two lookup fields based on the values they entered during the first submission. 

The "New Lead" button is a custom button using a URL hack (ref: http://www.salesforceben.com/salesforce-url-hacking-tutorial/ ). The button functions correctly if I use the standard "New" record button on the object. It auto-fills the approrpriate fields as intented. However, when using it in the VF page, it brings me back to the correct VF page, but clears out the fields. 

I know the values are being passed through correctly, as they show up in the URL after clicking "New Lead." I can't figure out why they are being cleared out on the actual lead field input boxes. Am I going about this the wrong way? 

Custom Button URL (this is referenced in the VF page as New_Lead):

Where the CFxxxxxxx values are the IDs found when using right click-inspect on the VF page for those fields
and the values after the equals sign are the two field values I am trying to pass through.

Relevant VF code below:
<apex:page StandardController="Lead_Form__c" showHeader="true" sidebar="false">
<apex:form >
<apex:pageBlock >           
 <apex:pageBlockSection title="Rep Info" columns="1" >

                  <apex:pageBlockSectionItem >
                      <apex:outputLabel value="Lookup Your Name " />
                      <apex:inputField value="{!Lead_Form__c.Ambassador__c}"/>

                  <apex:pageBlockSectionItem >
                      <apex:outputLabel value="Lookup Location " />
                      <apex:inputField value="{!Lead_Form__c.Location__c}"/>
                <apex:commandButton action="{!quicksave}" value="Save Lead" oncomplete="updateMessage();"  reRender="script_block" " />
                <apex:commandButton action="{!URLFOR($Action.Lead_Form__c.New_Lead, Id)}" id="New_Lead" value="New Lead" " />

Troy SearcyTroy Searcy
To add to this, I have also tried the following values in the URL hack:
1) Tried using Ambassador__c and Location__c rather than AmbassadorID__c and LocationID__c
2) Tried using the field ID values without "CF" in front
3) Tried using the field ID values obtained in Setup rather than the IDs from the VF page inspect