SF_ConvertLeads


SF_ConvertLeads


Usage

You can use SF_ConvertLeads to convert lead records to accounts/contacts/opportunities.  SF_ConvertLeads takes as input a local SQL Server table you create called the Input table. At a minimum, the Input table must have the following columns: 

 CREATE TABLE [dbo].[LeadConvert](  

 [LeadID] [nvarchar](18) NULL,  

 [convertedStatus] [nvarchar](255) NULL,  

 [Error] [nvarchar](512) NULL,  

 [AccountID] [nvarchar](18) NULL,  

 [OpportunityID] [nvarchar](18) NULL,  

 [ContactID] [nvarchar](18) NULL  

  ) ON [PRIMARY]  

Make sure to examine the Error column in the Result table after running the command to look for possible errors. 

Syntax

 EXEC SF_ConvertLeads 𝘭𝘪𝘯𝘬𝘦𝘥_𝘴𝘦𝘳𝘷𝘦𝘳, load_SQL_Table, options  

where 

  • linked_server—the linked server name. 

  • load_SQL_Table—input table

  • options—options for SF_ConvertLeads

Basic Examples 

 Exec SF_ConvertLeads 'SALESFORCE', 'LeadConvert' 

 Exec SF_ConvertLeads 'SALESFORCE', 'LeadConvert', 'ignorefailures(50)' 

Adding Additional Columns to the Table 

You can add additional columns to the table. The table below lists these additional columns, their data types, and gives a brief description of each. 

Name  Type  Description 
accountID  nvarchar(18) NULL  ID of the Account into which the lead will be merged. Required only when updating an existing account, including person accounts. If no accountID column is specified, then the API creates a new account. DBAmp will populate this column with the ID of the newly created Account.  
contactID  nvarchar(18) NULL  ID of the Contact into which the lead is merged (this contact must be associated with the specified accountID, and an accountID must be specified). Although required only when updating an existing contact, it is important If you are converting a lead into a person account, do not specify the contactID or an error results. Specify only the accountID of the person account. If no contactID is specified, then the API creates a new contact that is implicitly associated with the Account. DBAmp will populate this column with the ID of the newly created Contact. 
convertedStatus  nvarchar(255) NULL  Valid LeadStatus value for a converted lead. Required. To obtain the list of possible values, you must query the LeadStatus object. For example: Select ID, MasterLabel from SALESFORCE_LS.CData.Salesforce.LeadStatus where IsConverted=true 
doNotCreateOpportunity  varchar(5) NULL  Specifies whether to create an Opportunity during lead conversion (false, the default) or not (true). Set this flag to true only if you do not want to create an opportunity from the lead. An opportunity is created by default. 
leadID  nvarchar(18) NULL  ID of the Lead to convert. Required. 
opportunityID  nvarchar(18) NULL  DBAmp populates the field with the ID of the newly created Opportunity 
opportunityName  nvarchar(80) NULL  Name of the opportunity to create. If this column is not included, then this value defaults to the company name of the lead. 
overwriteLeadSource  varchar(5) NULL  Specifies whether to overwrite the LeadSource field on the target Contact object with the contents of the LeadSource field in the source Lead object (true), or not (false, the default). To set this field to true, you must specify a contactID for the target contact. 
ownerID  nvarchar(18) NULL  Specifies the ID of the person to own any newly created account, contact, and opportunity. If the client application does not specify this value, then the owner of the new object will be the owner of the lead. 
sendNotificationEmail  varchar(5) NULL  Specifies whether to send a notification email to the owner specified in the ownerID (true) or not (false, the default).