ConvertLead
Converts a Lead record into an Account, Contact, and optionally an Opportunity.
Note: This procedure makes use of indexed parameters. Indexed parameters facilitate providing multiple instances a single parameter as inputs for the procedure.
Suppose there is an input parameter named Param#. To input multiple instances of an indexed parameter like this, execute:
EXEC ProcedureName Param#1 = "value1", Param#2 = "value2", Param#3 = "value3"
In the table below, indexed parameters are denoted with a '#' character at the end of their names.
Input
| Name | Type | Description |
| AccountId# | String | ID of the existing Account to associate with the converted lead. Required only when merging into an existing account. If omitted, a new Account is created automatically, assuming the user has sufficient access. |
| ContactId# | String | ID of the existing Contact to associate with the converted lead. Must be linked to the specified AccountId. Leave blank when converting to a person account. If omitted, a new Contact is created. |
| ConvertedStatus# | String | Required status to assign to the Lead upon conversion. Must be a valid LeadStatus value where IsConverted is 'true'. Retrieve available values via: SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true. |
| DoNotCreateOpportunity# | String | Set to 'true' to skip opportunity creation during lead conversion. Defaults to 'false', meaning an opportunity is created unless explicitly disabled. |
| LeadId# | String | ID of the Lead record to convert. This is a required field. |
| OpportunityName# | String | Name to assign to the opportunity created during conversion. If omitted, defaults to the Lead's company name. Must be blank if DoNotCreateOpportunity is 'true'. |
| OverwriteLeadSource# | String | Set to 'true' to overwrite the LeadSource field on the resulting Contact with the Lead's LeadSource value. Requires that ContactId is provided. |
| OwnerId# | String | ID of the user who will own the new Account, Contact, and Opportunity records. Defaults to the Lead owner if not specified. Does not affect existing records. |
| SendNotificationEmail# | String | Set to 'true' to send a notification email to the new owner defined by OwnerId. Defaults to 'false'.
The default value is FALSE. |
Result Set Columns
| Name | Type | Description |
| AccountId | String | ID of the Account record associated with the converted lead, whether newly created or existing. |
| ContactId | String | ID of the Contact record associated with the converted lead, whether newly created or existing. |
| LeadId | String | ID of the original Lead record that was converted. |
| OpportunityId | String | ID of the newly created Opportunity, if one was created during conversion. |
| Success | String | Indicates whether the lead conversion succeeded (true) or failed (false). |
| Errors | String | List of error messages returned by Salesforce if the conversion failed, including error codes and descriptions. |