Lead

Represents a prospect or potential Opportunity.

Supported Calls

create(), delete(), describeLayout(), describeSObjects(), getDeleted(), getUpdated(), merge(), query(), retrieve(), search(), undelete(), update(), upsert()

Fields

Field Details
Address (beta)
Type
address
Properties
Filter, Nillable
Description
The compound form of the address. Read-only. See Address Compound Fields for details on compound address fields.
AnnualRevenue
Type
currency
Properties
Create, Filter, Nillable, Sort, Update
Description
Annual revenue for the company of the lead.
City
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
City for the address of the lead.
CleanStatus
Type
picklist
Properties
Create, Filter, Group, Nillable, Restricted picklist, Sort, Update
Description
Indicates the record’s clean status as compared with Data.com. Values are: In Sync, Different, Reviewed, Not Found, Inactive, Not Compared, Select Match, or Skipped.
Company
Type
string
Properties
Create, Filter, Group, Sort, Update
Description
Required. Company of the lead.
Note
If person account record types have been enabled, and if the value of Company is null, the lead converts to a person account.
CompanyDunsNumber
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
The Data Universal Numbering System (D-U-N-S) number is a unique, nine-digit number assigned to every business location in the Dun&Bradstreet database that has a unique, separate, and distinct operation. D-U-N-S numbers are used by industries and organizations around the world as a global standard for business identification and tracking. Maximum size is 9 characters.
Note
This field is only available to organizations that use Data.com Prospector or Data.com Clean.
ConnectionReceivedId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
ID of the PartnerNetworkConnection that shared this record with your organization. This field is only available if you have enabled Salesforce to Salesforce.
ConnectionSentId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
ID of the PartnerNetworkConnection that you shared this record with. This field is only available if you have enabled Salesforce to Salesforce. Beginning with API version 15.0, the ConnectionSentId field is no longer supported. The ConnectionSentId field is still visible, but the value is null. You can use the new PartnerNetworkRecordConnection object to forward records to connections.
ConvertedAccountId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
Object reference ID that points to the Account into which the Lead has been converted.
ConvertedContactId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
Object reference ID that points to the Contact into which the Lead has been converted.
ConvertedDate
Type
date
Properties
Filter, Group, Nillable, Sort
Description
Date on which this Lead was converted.
ConvertedOpportunityId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
Object reference ID that points to the Opportunity into which the Lead has been converted.
Country
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Country for the address of the lead.
CountryCode
Type
picklist
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
The ISO country code for the lead’s address.
CurrencyIsoCode
Type
picklist
Properties
Create, Defaulted on create, Filter, Group, Nillable, Restricted picklist, Sort, Update
Description
Available only for organizations with the multicurrency feature enabled. Contains the ISO code for any currency allowed by the organization.
Description
Type
textarea
Properties
Create, Nillable, Update
Description
Description of the lead.
Division
Type
picklist
Properties
Filter, Group, Restricted picklist, Sort
Description
A logical segment of your organization’s data. Available only if the organization has the Division permission enabled.
Email
Type
email
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Email address for the lead.
EmailBouncedDate
Type
dateTime
Properties
Filter, Nillable, Sort, Update
Description
If bounce management is activated and an email sent to the lead bounced, the date and time the bounce occurred.
EmailBouncedReason
Type
string
Properties
Filter, Group, Nillable, Sort, Update
Description
If bounce management is activated and an email sent to the lead bounced, the reason the bounce occurred.
Fax
Type
phone
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Fax number for the lead.
FirstName
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
First name of the lead. Limited to 40 characters.
HasOptedOutOfEmail
Type
boolean
Properties
Create, Defaulted on create, Filter, Update
Description
Indicates whether the lead has opted out of email (true) or not (false). Label is Email Opt Out.
Industry
Type
picklist
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Industry the lead works in.
IsConverted
Type
boolean
Properties
Create, Defaulted on create, Filter, Group, Sort
Description
Indicates whether the Lead has been converted (true) or not (false). Label is Converted.
IsDeleted
Type
boolean
Properties
Defaulted on create, Filter
Description
Indicates whether the object has been moved to the Recycle Bin (true) or not (false). Label is Deleted.
IsUnreadByOwner
Type
boolean
Properties
Create, Defaulted on create, Filter, Group, Sort, Update
Description
If true, lead has been assigned, but not yet viewed. See Unread Leads for more information. Label is Unread By Owner.
Jigsaw
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
References the ID of a contact in Data.com. If a lead has a value in this field, it means that a contact was imported as a lead from Data.com. If the contact (converted to a lead) was not imported from Data.com, the field value is null. Maximum size is 20 characters. Available in API version 22.0 and later. Label is Data.com Key.
Important
The Jigsawfield is exposed in the API to support troubleshooting for import errors and reimporting of corrected data. Do not modify the value in the Jigsaw field.
LastActivityDate
Type
date
Properties
Filter, Group, Nillable, Sort
Description
Value is one of the following, whichever is the most recent:
  • Due date of the most recent event logged against the record.
  • Due date of the most recently closed task associated with the record.
LastName
Type
string
Properties
Create, Filter, Group, Sort, Update
Description
Required. Last name of the lead. Limited to 80 characters.
LastReferencedDate
Type
date
Properties
Filter, Nillable, Sort, Update
Description
The timestamp for when the current user last viewed a record related to this record.
LastViewedDate
Type
date
Properties
Filter, Nillable, Sort, Update
Description
The timestamp for when the current user last viewed this record. If this value is null, this record might only have been referenced (LastReferencedDate) and not viewed.
Latitude (beta)
Type
double
Properties
Create, Filter, Nillable, Sort, Update
Description
Used with Longitude to specify the precise geolocation of an address. Acceptable values are numbers between –90 and 90 with up to 15 decimal places.
Longitude (beta)
Type
double
Properties
Create, Filter, Nillable, Sort, Update
Description
Used with Latitude to specify the precise geolocation of an address. Acceptable values are numbers between –180 and 180 with up to 15 decimal places.
LeadSource
Type
picklist
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Source from which the lead was obtained.
MasterRecordId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
If this object was deleted as the result of a merge, this field contains the ID of the record that was kept. If this object was deleted for any other reason, or has not been deleted, the value is null.
Note
When using Apex triggers to determine which record was deleted in a merge event, this field’s value is the ID of the record that was kept only in Trigger.old. In Trigger.new, the value is null.
MiddleName (beta)
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Middle name of the lead. Maximum size is 40 characters. Contact salesforce.com Customer Support to enable this field.
MobilePhone
Type
phone
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Mobile phone number for the lead.
Name
Type
string
Properties
Filter, Group, Sort
Description
Concatenation of FirstName, MiddleName (beta), LastName, and Suffix (beta). Maximum size is 121 characters.
NumberOfEmployees
Type
int
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Number of employees at the lead’s company. Label is Employees.
OwnerId
Type
reference
Properties
Create, Defaulted on create, Filter, Group, Sort, Update
Description
ID of the owner of the lead.
PartnerAccountId
Type
reference
Properties
Filter, Nillable
Description
ID of the partner account for the partner user that owns this lead. Available only if Partner Relationship Management is enabled OR Communities is enabled and you have partner portal licenses.
Note
If you are uploading leads using API version 15.0 or earlier, and one of the leads in the batch has a partner user as the owner, the Partner Account field on all leads in the batch is set to that partner user’s account regardless of whether the partner user is the owner. In version 16.0, the Partner Account field is set to the appropriate account for the partner user that owns the lead. If the owner of the lead is not a partner user, this field remains blank.
Phone
Type
phone
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Phone number for the lead.
PhotoUrl
Type
url
Properties
Filter, Group, Sort
Description

Path to be combined with the URL of a Salesforce instance (for example, https://na1.salesforce.com/) to generate a URL to request the social network profile image associated with the lead. Generated URL returns an HTTP redirect (code 302) to the social network profile image for the lead.

Blank if Social Accounts and Contacts isn't enabled for the organization or if Social Accounts and Contacts has been disabled for the requesting user.

PostalCode
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Postal code for the address of the lead. Label is Zip/Postal Code.
Rating
Type
picklist
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Rating of the lead.
RecordTypeId
Type
reference
Properties
Create, Filter, Nillable, Update
Description
ID of the record type assigned to this object.
Salutation
Type
picklist
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Salutation for the lead.
State
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
State for the address of the lead.
StateCode
Type
picklist
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
The ISO state code for the lead’s address.
Status
Type
picklist
Properties
Create, Defaulted on create, Filter, Group, Sort, Update
Description
Status code for this converted lead. Status codes are defined in Status and represented in the API by the LeadStatus object.
Street
Type
textarea
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Street number and name for the address of the lead.
Suffix (beta)
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Name suffix of the lead. Maximum size is 40 characters. Contact salesforce.com Customer Support to enable this field.
Title
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Title for the lead, for example CFO or CEO.
Website
Type
url
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Website for the lead.
Note
If you import Lead data and need to set the value for an audit field, such as CreatedDate, contact salesforce.com. Audit fields are automatically updated during API operations unless you request to set these fields yourself..

Converted Leads

Leads have a special state to indicate that they have been converted into an Account, Contact, and optionally, an Opportunity. Your client application can convert leads via the convertLead() call. Users can also convert leads through the user interface. Once a lead has been converted, it is read-only. You can’t update or delete a converted lead. However, you can query converted lead records.

Leads have several fields that indicate their converted status. These special fields are set when converting the lead in the user interface.

Note
If person account record types have been enabled, and if the value of Company is null, the lead converts to a person account.

Unread Leads

Leads have a special state to indicate that they have not been viewed or edited by the lead owner. In the user interface, this is helpful for users to know which leads have been assigned to them but which they have not touched yet. IsUnreadByOwner is true if the lead owner has not yet viewed or edited the lead, and false if the lead owner has viewed or edited the lead at least once.

Lead Status Picklist

Each Status value corresponds to either a converted or unconverted status in the lead status picklist, as defined in the user interface. To obtain the lead status values in the picklist, a client application can query LeadStatus.

You can’t convert a lead via the API by changing Status to one of the converted lead status values. When you convert qualified leads into an account, contact, and opportunity, you can select one of the converted status types for the lead. Leads with a converted status type are no longer available in the Leads tab, although you can include them in reports.

Usage

To update a Lead or to convert one with convertLead(), your client application must log in with the “Edit” permission on leads.

When you create, update, or upsert a lead, your client application can have the lead automatically assigned to one or more User records based on assignment rules that have been configured in the user interface.

To use this feature, your client application needs to set either of the following options (but not both) in the AssignmentRuleHeader used in create or update:

Field Field Type Details
assignmentRuleId reference ID of the assignment rule to use. Can be an inactive assignment rule. If unspecified and useDefaultRule is true, then the default assignment rule is used.

To find the ID for a given assignment rule, query the AssignmentRule object (specifying RuleType="leadAssignment"), iterate through the returned AssignmentRule records, find the one you want to use, retrieve its ID, and then specify its ID in this field in the AssignmentRuleHeader.

useDefaultRule boolean Specifies whether to use the default rule for rule-based assignment (true) or not (false). Default rules are assigned in the user interface.

Java Sample

The following Java sample shows how to automatically assign a newly created lead.

package com.doc.samples; 
import java.net.MalformedURLException; 
import java.net.URL; 
import java.rmi.RemoteException; 
import javax.xml.rpc.ServiceException;

import com.sforce.soap.enterprise.LoginResult; 
import com.sforce.soap.enterprise.QueryResult; 
import com.sforce.soap.enterprise.SaveResult; 
import com.sforce.soap.enterprise.SforceServiceLocator; 
import com.sforce.soap.enterprise.SoapBindingStub; 
import com.sforce.soap.enterprise._AssignmentRuleHeader; 
import com.sforce.soap.enterprise._SessionHeader; 
import com.sforce.soap.enterprise.fault.LoginFault; 
import com.sforce.soap.enterprise.fault.UnexpectedErrorFault; 
import com.sforce.soap.enterprise.sobject.Lead; 
import com.sforce.soap.enterprise.sobject.SObject; 

public class LeadAssignment
{

  static LeadAssignment _leadAssignment;

  public static void main(String[] args)
  { 
    _leadAssignment = new LeadAssignment(); 
    try { 
      _leadAssignment.CreateLead(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
    } 
  } 

  public void CreateLead() throws UnexpectedErrorFault, LoginFault, 
    RemoteException, ServiceException
  { 
    //Create the proxy binding and login 
    SoapBindingStub binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
    LoginResult lr = binding.login("user@domain.net", "secret"); 
 
    //Reset the binding to use the endpoint returned from login 
    binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, 
        lr.getServerUrl());
 
    //Create the session id header, and add it to the proxy binding 
    _SessionHeader sh = new _SessionHeader(); 
    sh.setSessionId(lr.getSessionId()); 
    binding.setHeader(
        new SforceServiceLocator().getServiceName().getNamespaceURI(),
        "SessionHeader", sh );
 
    //Create a new case and assign various properties 
    Lead lead = new Lead(); 
 
    lead.setFirstName("Joe"); 
    lead.setLastName("Smith"); 
    lead.setCompany("ABC Corporation"); 
    lead.setLeadSource("API"); 
    //The lead assignment rule will assign any new leads that 
    //have "API" as the LeadSource to a particular user
 
    //Create the assignment rule header and add it to the proxy binding _AssignmentRuleHeader arh = new _AssignmentRuleHeader(); //In this sample we will look for a particular rule and if found
    //use the id for the lead assignment. If it is not found we will
    //instruct the call to use the current default rule. You can't use
    //both of these values together. QueryResult qr = binding.query("Select Id From AssignmentRule where Name = " + "'Mass Mail Campaign' and RuleType = 'leadAssignment'"); if (qr.getSize() == 0) { arh.setUseDefaultRule(new Boolean(true)); } else { arh.setAssignmentRuleId(qr.getRecords(0).getId()); } binding.setHeader( new SforceServiceLocator().getServiceName().getNamespaceURI(), "AssignmentRuleHeader", arh); // Every operation that results in a new or updated case, will
    // use the specified rule until the header is removed from the
    // proxy binding. SaveResult[] sr = binding.create(new SObject[] {lead}); for (int i=0;i<sr.length;i++) { if (sr[i].isSuccess()) { System.out.println("Successfully created lead with id of: " + sr[i].getId().getValue() + "."); } else { System.out.println("Error creating lead: " + sr[i].getErrors(0).getMessage()); } } // This call effectively removes the header, the next lead will
    // be assigned to the default lead owner. Remember to add the
    // session header back in. binding.clearHeaders(); binding.setHeader( new SforceServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh); } }

C# Sample

The following C# sample shows how to automatically assign a newly created lead.

using System;
using System.Collections.Generic;
using System.Text;
using LeadAssignment.sforce;

namespace LeadAssignment
{
    class LeadAssignment
    {
        private SforceService binding;

        private static readonly string Username = "ENTERUSERNAME";
        private static readonly string Password = "ENTERPASSWORD";

        /// <summary>
        /// Create the proxy binding and login
        /// </summary>
        private LeadAssignment() { this.binding = new SforceService(); LoginResult lr = binding.login(LeadAssignment.Username, LeadAssignment.Password); // Reset the binding to use the endpoint returned from login
            this.binding.Url = lr.serverUrl; // Create the session ID header and add it to the proxy binding
            this.binding.SessionHeaderValue = new SessionHeader(); this.binding.SessionHeaderValue.sessionId = lr.sessionId; } [STAThread] static void Main(string[] args) { LeadAssignment leadAssignment = new LeadAssignment(); try { leadAssignment.CreateLead(); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); Console.WriteLine(e.InnerException); } } public void CreateLead() { // Create a new Lead and assign various properties Lead lead = new Lead(); lead.FirstName = "John"; lead.LastName = "Brown"; lead.Company = "ABC Corporation"; lead.LeadSource = "Advertisement"; // Setting the lead source for a pre-existing lead assignment rule. This
            // rule was created outside of this sample and will assign any new leads
            // that have "Advertisement" as the LeadSource to a particular user

            // Create the assignment rule header and add it to the proxy binding AssignmentRuleHeader arh = new AssignmentRuleHeader(); // In this sample we will look for a particular rule and if found
            // use the id for the lead assignment. If it is not found we will
            // instruct the call to use the current default rule. Both these
            // values can't be used together. QueryResult qr = binding.query("Select Id from AssignmentRule where Name = " + "'Mass Mail Campaign' and SobjectType = 'lead'"); if (qr.size == 0) { arh.useDefaultRule = true; } else { arh.assignmentRuleId = qr.records[0].Id; } binding.AssignmentRuleHeaderValue = arh; // Every operation that results in a new or updated lead will use the
            // specified rule until the header is removed from the proxy binding SaveResult[] sr = binding.create(new sObject[] { lead }); foreach (SaveResult s in sr) { if (s.success) { Console.WriteLine("Successfully created Lead with ID: {0}", s.id); } else { Console.WriteLine("Error creating Lead: {0}", s.errors[0].message); } } // This call effectively removes the header. The next lead will be assigned
            // to the default lead owner. binding.AssignmentRuleHeaderValue = null; } } }
© Copyright 2000–2014 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.