Search code examples
salesforcecrmsoqllead

How can I refer to converted Lead information?


I have created a Custom Button as below:

Display Type: List Button Behaviour: Display in existing window wihtout sidebar or header Content: URL

Details:

 ../a02/e? &00N2800000AaCYu={!Opportunity.Id}
 &CF00N2800000BHtdT={!Opportunity.Name} &CF00N2800000BHtdY={!Lead.Name}
 &00N2800000BHvSK={!Lead.Id} &retURL={!Opportunity.Id}

I am using this button to Create new custom object from Opportunity. I am trying to pass some of my original information from converted Lead to new object. But above Bold codes will not provide any information. Although I still can use SOQL to extract information but I am not sure how to merge SOQL with this URL configurations. Is there any way that I can do this?


Solution

  • I found a workaround for this by using JavaScript:

    Solution:

    Behaviour: Execute JavaScript

    Content Source: OnClick JavaScript

    Details:

    {!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
    {!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")} 
    
    var myLead = sforce.connection.query("SELECT Id,Name From Lead where ConvertedOpportunityID  ='{!Opportunity.Id}' limit 1");
    
    records = myLead.getArray("records"); 
    var myLeadId = records[0].Id;
    var myLeadName = records[0].Name;
    
    
    window.parent.location.href = "../a02/e?" + 
                                  "&00N2800000AaCYu=" + '{!Opportunity.Id}' + 
                                  "&CF00N2800000BHtdT=" + '{!Opportunity.Name}' +
                                  "&CF00N2800000BHtdY=" + myLeadName +
                                  "&00N2800000BHvSK=" + myLeadId + 
                                  "&retURL=" + '{!Opportunity.Id}' ;
    

    I am still interested to find better answers.