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

Need to fire a trigger upon lead conversion

I'm trying to do some updates when a lead is converted.  I have a custom object that is related to a lead, and when the lead is converted, I want my custom object to be related to the new account that is created, or the account to which it is merged.  As I've searched the documentation, all I can find are references explaining how to code the actual conversion, but I just want to do some updates when that happens.  Does anyone have ideas how to do this?  Thanks!

My approach would be to override the Convert button with S-control in order to 'trap' the convert.  Then use sforce.connection.convertLead to run default conversion, then while you still have control make changes to accounts, whatever based on result.  e.g.

  var convert = new sforce.LeadConvert();
  convert.convertedStatus = convertedStatus;
  convert.doNotCreateOpportunity = true;
  convert.leadId ="{!Lead.Id}";
  result = sforce.connection.convertLead([convert]);
  if (result[0].getBoolean("success")) {
      var accountId = result[0].accountId;            // Target record
      // modify account record
Thanks Lolt!  I'll give it a try and let you know how it goes.  I appreciate the detailed response - that will be a big help.
sandeep kumarsandeep kumar
There are two convert buttons. One on the Lead pagelayout and another on the Edit page. How to make this work like the Convert button on the Lead page can be overriden.There is no override of the convert button on the Edit page. How to make this work. There is some URL that is passed. Would like to know how exactly to make it work. A functional example would be highly appreciated