How can I assure that the assigned lead owner remains the owner when the lead is converted?

When you assign a lead owner, that lead owner must accept the lead for them to remain the owner of the converted lead. If the lead owner doesn't accept the lead and another salesperson converts the lead into an opportunity, then that second person becomes the owner of the converted lead. You can assure that the assigned lead owners remain the owners of converted leads by creating a Groovy script to automatically accept the lead.

To automatically accept the lead for the assigned lead owner, create a Before Update in Database trigger on the Sales Lead object. Here is a sample script:

if (isAttributeChanged('OwnerId') && OwnerId != null){
  setAttribute('LeadAcceptedFlag', 'Y')
}

Steps to Create the Trigger

  1. Enter a sandbox with Application Composer as one of the tools.
  2. Open Application Composer by selecting it from the sandbox Tools menu.
  3. In the left pane, search for the Sales Lead object (callout 1 in the screenshot).

    Create Object Trigger page with callouts identifying elements described in the text.
  4. Expand Sales Lead under Standard Objects (callout 2).
  5. Click Server Scripts (callout 3).
  6. In the Server Scripts Sales Lead page, click the Triggers tab (callout 1 in the screenshot).

    Server Scripts Sales Lead page with callouts identifying elements described in the text.
  7. Click Add a new trigger (callout 2).
  8. In the Create Object Trigger page Name Trigger list, select Before Update in Database (callout 1 in the screenshot).

    Create Object Trigger page with callouts identifying elements described in the text.
  9. Enter a trigger name.
  10. Enter the Groovy script (callout 2).
  11. You can validate the script by clicking Validate on the right side of the Trigger Definition section.
  12. Click Save and Close.
You must publish the sandbox for the trigger to become active.