0

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)"
    rendered="{!NOT(ISNULL(a.Id))}">
        {!a.Name}
</apex:outputLink>

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 Sep 20 '18 at 7:45
  • check my answer and try that appproach – Santanu Boral Sep 20 '18 at 8:54
0

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}"/>
</apex:commandLink>

Controller

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 Sep 20 '18 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 – Santanu Boral Sep 20 '18 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.