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
Nick KeehanNick Keehan 

Vf Page - Return URL or URL to populate VF page Field

HI Guys.

I have a VF page used top search for a Lead. This will then take the user with the Lead id to another VF page. Once this VF page is complete, i would like it to come back to this search page with the lead still populated.

e.g. search box is a street name, Update the lead via second vf page, then return to original page."tester" is the other VF page.
<apex:outputlink value="/apex/loc5?id={!a.id}&retURL=%2Fapex%2Ftester">{!a.Street}</apex:outputlink>
Above brings the user back to the below page, however i would liek it to be still populates with the street name if possible?


VF Page
<apex:page extensions="CreatingWizard2" standardController="Lead" showHeader="false" sidebar="false" standardStylesheets="false" >
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">    
<div class="slds"> 

 
<head>
  <title>Salesforce Lightning Design System Trailhead Module</title>
<apex:stylesheet value="/resource/SLDS0102/assets/styles/salesforce-lightning-design-system-ltng.css"/>
</head>   



<apex:form >


<fieldset class="slds-box slds-theme--default slds-container--end">
<legend id="newaccountform" class="slds-text-heading--medium slds-p-vertical--medium">Lead Address Search</legend>  
<apex:pageMessages id="showmsg"></apex:pageMessages>

         <div class="slds-form-element">            
         <label class="slds-form-element__label">Street Name</label>
         <div class="slds-form-element__control">
         <apex:inputText value="{!searchstring2}" styleclass="slds-input"/>
         </div>
         <apex:commandButton action="{!search2}" value="Search" styleClass="slds-button slds-button--brand slds-m-top--medium"/>  

</div>

</fieldset>
 
 
 
<fieldset class="slds-box slds-theme--default slds-container--end">     
<legend id="newaccountform" class="slds-text-heading--medium slds-p-vertical--medium">Search Results</legend>
<apex:pageBlock rendered="{!or(searchstring != null, searchstring2 != null) }">  

   <apex:pageblockTable value="{!acc}" var="a">  
     <apex:column >  
      <apex:outputlink value="/apex/loc5?id={!a.id}&retURL=%2Fapex%2Ftester">{!a.Street}</apex:outputlink>  

     </apex:column>
    </apex:pageBlockTable>   

</apex:pageBlock>  
<apex:actionFunction name="copyAndRerenderDepdPLFields" oncomplete="return copyDepdPLValues('{!$Component.DestID}' ,'{!$Component.SourceID}');" rerender="DestID" />
</fieldset> 


  
<script>
function copyContPLValues (DestContPListID,SourceContPListID) {
    document.getElementById(DestContPListID).value = document.getElementById(SourceContPListID).value;
    copyAndRerenderDepdPLFields();
}

function copyDepdPLValues (DestDepdPListID,SourceDepdPListID) {
    document.getElementById(DestDepdPListID).value = document.getElementById(SourceDepdPListID).value;
}
</script>

 

</apex:form>            
</div></html>
</apex:page>

Class
public class CreatingWizard2{

public list <lead> acc {get;set;}  
   public string searchstring {get;set;}  
      public string searchstring2 {get;set;} 
   public CreatingWizard2(ApexPages.StandardController controller) {  
   }  
   public void search2(){  
       if(searchstring2 == '' && searchstring == '')
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Please enter an Account Number'));   
     string searchquery='select Lastname,id,Street,Street_Name__c,Street_Number__c from lead where Street_Name__c= :searchstring2 AND Iown__c=True ORDER BY Street_Number__c ASC NULLS LAST Limit 20';  
     acc= Database.query(searchquery);  
   }  
  
 
   public void clear(){  
   acc.clear();  
   }  
 

Lead lead;
 
 
public Lead getLead() {
if(lead == null) lead = new Lead();
return lead;
}

 
    public PageReference create() {
 
         PageReference opptyPage = new PageReference('/001/e?retURL=%2F001%2Fo&RecordType=012200000000iKt&ent=Account');
         opptyPage.setRedirect(true);
 
         return Page.tester;
        } 
 

}



 
Best Answer chosen by Nick Keehan
Nick KeehanNick Keehan
Solved by this article.

http://salesforce.stackexchange.com/questions/28390/prefill-visualforce-inputfield-from-url-parameter-without-custom-controller