I have two object one standard object Leads and one custom object tractor.and tractor is a lookup field in lead object.i am trying to include three input fields and a button for searching a tractor in lead edit page using a button and vf page. everything is working fine except that,on clicking one particular item in this list i need to populate that value in the lookup field on the lead detail page.

i tried some url hacking things like this

<apex:outputLink value="javascript:top.window.opener.lookupPick2('editPage','CF00Nq00000025801_lkid','CF00Nq00000025801','{!a.Id}','{!a.Name}', false)"

but its not working for me.can any one suggest me some idea to achieve this requirement.

  • @Santanu Boral can you explain some what or give an example of that.because i am very new to sf.i need to redirect back to my lead detail page and populate the selected value in the custom lookup field
    – ebk
    Commented Sep 20, 2018 at 7:45
  • check my answer and try that appproach Commented Sep 20, 2018 at 8:54

1 Answer 1


Since you have visualforce page, so clicking the link of the displayed custom object record, save this in the controller and refresh the page.

It is not encouraged to use URL hacking which is very fragile.

Use apex:commandLink to call the controller function and pass the value from your page.

<apex:commandLink value="{!a.Name}" action="{!processLinkClick}">
    <apex:param name="customLookupFieldName" value="{!a.Id}" assignTo="{!customLookupField}"/>


public  class LeadTractorExtension{

    public String customLookupField {get; set;}
    public PageReference processLinkClick() {

        //here save the lead record and return to lead detail page

  • thanks for your reply. TractorInfo__c is my customlookup field.currently i am using an extension controler.i am getting an error as invlaid character in identifier on declaring as follows public String TractorInfo__c{get; set;} can you please post the code for updating the lead and redirecting the page to lead detail page
    – ebk
    Commented Sep 20, 2018 at 9:19
  • You could edit your question to update your code, you should first try with learning some trailheads and could able to get in there Commented Sep 20, 2018 at 10:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .