No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Newer Version Available
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) |
|
| AnnualRevenue |
|
| City |
|
| CleanStatus | |
| Company |
|
| CompanyDunsNumber |
|
| ConnectionReceivedId | |
| ConnectionSentId |
|
| ConvertedAccountId |
|
| ConvertedContactId |
|
| ConvertedDate |
|
| ConvertedOpportunityId |
|
| Country |
|
| CountryCode |
|
| CurrencyIsoCode |
|
| Description |
|
| Division |
|
|
|
| EmailBouncedDate |
|
| EmailBouncedReason |
|
| Fax |
|
| FirstName |
|
| HasOptedOutOfEmail |
|
| Industry |
|
| IsConverted |
|
| IsDeleted |
|
| IsUnreadByOwner |
|
| Jigsaw |
|
| LastActivityDate |
|
| LastName |
|
| LastReferencedDate |
|
| LastViewedDate |
|
| Latitude (beta) | |
| Longitude (beta) | |
| LeadSource |
|
| MasterRecordId |
|
| MiddleName (beta) |
|
| MobilePhone |
|
| Name |
|
| NumberOfEmployees |
|
| OwnerId |
|
| PartnerAccountId | |
| Phone |
|
| PhotoUrl |
|
| PostalCode |
|
| Rating |
|
| RecordTypeId |
|
| Salutation |
|
| State |
|
| StateCode |
|
| Status |
|
| Street |
|
| Suffix (beta) |
|
| Title |
|
| Website |
|
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.
- ConvertedAccountId
- ConvertedContactId
- ConvertedDate
- ConvertedOpportunityId
- IsConverted
- Status
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:
Java Sample
The following Java sample shows how to automatically assign a newly created lead.
1swfobject.registerObject("clippy.codeblock-0", "9");package com.doc.samples;
2import java.net.MalformedURLException;
3import java.net.URL;
4import java.rmi.RemoteException;
5import javax.xml.rpc.ServiceException;
6
7import com.sforce.soap.enterprise.LoginResult;
8import com.sforce.soap.enterprise.QueryResult;
9import com.sforce.soap.enterprise.SaveResult;
10import com.sforce.soap.enterprise.SforceServiceLocator;
11import com.sforce.soap.enterprise.SoapBindingStub;
12import com.sforce.soap.enterprise._AssignmentRuleHeader;
13import com.sforce.soap.enterprise._SessionHeader;
14import com.sforce.soap.enterprise.fault.LoginFault;
15import com.sforce.soap.enterprise.fault.UnexpectedErrorFault;
16import com.sforce.soap.enterprise.sobject.Lead;
17import com.sforce.soap.enterprise.sobject.SObject;
18
19public class LeadAssignment
20{
21
22 static LeadAssignment _leadAssignment;
23
24 public static void main(String[] args)
25 {
26 _leadAssignment = new LeadAssignment();
27 try {
28 _leadAssignment.CreateLead();
29 } catch (Exception e) {
30 e.printStackTrace();
31 }
32 }
33
34 public void CreateLead() throws UnexpectedErrorFault, LoginFault,
35 RemoteException, ServiceException
36 {
37 //Create the proxy binding and login
38 SoapBindingStub binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
39 LoginResult lr = binding.login("user@domain.net", "secret");
40
41 //Reset the binding to use the endpoint returned from login
42 binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
43 lr.getServerUrl());
44
45 //Create the session id header, and add it to the proxy binding
46 _SessionHeader sh = new _SessionHeader();
47 sh.setSessionId(lr.getSessionId());
48 binding.setHeader(
49 new SforceServiceLocator().getServiceName().getNamespaceURI(),
50 "SessionHeader", sh );
51
52 //Create a new case and assign various properties
53 Lead lead = new Lead();
54
55 lead.setFirstName("Joe");
56 lead.setLastName("Smith");
57 lead.setCompany("ABC Corporation");
58 lead.setLeadSource("API");
59 //The lead assignment rule will assign any new leads that
60 //have "API" as the LeadSource to a particular user
61
62 //Create the assignment rule header and add it to the proxy binding
63 _AssignmentRuleHeader arh = new _AssignmentRuleHeader();
64
65 //In this sample we will look for a particular rule and if found
66 //use the id for the lead assignment. If it is not found we will
67 //instruct the call to use the current default rule. You can't use
68 //both of these values together.
69 QueryResult qr = binding.query("Select Id From AssignmentRule where Name = " +
70 "'Mass Mail Campaign' and RuleType = 'leadAssignment'");
71 if (qr.getSize() == 0) {
72 arh.setUseDefaultRule(new Boolean(true));
73 } else {
74 arh.setAssignmentRuleId(qr.getRecords(0).getId());
75 }
76
77 binding.setHeader(
78 new SforceServiceLocator().getServiceName().getNamespaceURI(),
79 "AssignmentRuleHeader", arh);
80
81 // Every operation that results in a new or updated case, will
82 // use the specified rule until the header is removed from the
83 // proxy binding.
84 SaveResult[] sr = binding.create(new SObject[] {lead});
85 for (int i=0;i<sr.length;i++) {
86 if (sr[i].isSuccess()) {
87 System.out.println("Successfully created lead with id of: " +
88 sr[i].getId().getValue() + ".");
89 }
90 else {
91 System.out.println("Error creating lead: " +
92 sr[i].getErrors(0).getMessage());
93 }
94 }
95
96 // This call effectively removes the header, the next lead will
97 // be assigned to the default lead owner. Remember to add the
98 // session header back in.
99 binding.clearHeaders();
100 binding.setHeader(
101 new SforceServiceLocator().getServiceName().getNamespaceURI(),
102 "SessionHeader", sh);
103
104 }
105}C# Sample
The following C# sample shows how to automatically assign a newly created lead.
1swfobject.registerObject("clippy.codeblock-1", "9");using System;
2using System.Collections.Generic;
3using System.Text;
4using LeadAssignment.sforce;
5
6namespace LeadAssignment
7{
8 class LeadAssignment
9 {
10 private SforceService binding;
11
12 private static readonly string Username = "ENTERUSERNAME";
13 private static readonly string Password = "ENTERPASSWORD";
14
15 /// <summary>
16 /// Create the proxy binding and login
17 /// </summary>
18 private LeadAssignment()
19 {
20 this.binding = new SforceService();
21 LoginResult lr = binding.login(LeadAssignment.Username, LeadAssignment.Password);
22
23 // Reset the binding to use the endpoint returned from login
24 this.binding.Url = lr.serverUrl;
25
26 // Create the session ID header and add it to the proxy binding
27 this.binding.SessionHeaderValue = new SessionHeader();
28 this.binding.SessionHeaderValue.sessionId = lr.sessionId;
29 }
30
31 [STAThread]
32 static void Main(string[] args)
33 {
34 LeadAssignment leadAssignment = new LeadAssignment();
35 try
36 {
37 leadAssignment.CreateLead();
38 }
39 catch (Exception e)
40 {
41 Console.WriteLine(e.Message);
42 Console.WriteLine(e.StackTrace);
43 Console.WriteLine(e.InnerException);
44 }
45 }
46
47 public void CreateLead()
48 {
49 // Create a new Lead and assign various properties
50 Lead lead = new Lead();
51
52 lead.FirstName = "John";
53 lead.LastName = "Brown";
54 lead.Company = "ABC Corporation";
55 lead.LeadSource = "Advertisement";
56 // Setting the lead source for a pre-existing lead assignment rule. This
57 // rule was created outside of this sample and will assign any new leads
58 // that have "Advertisement" as the LeadSource to a particular user
59
60 // Create the assignment rule header and add it to the proxy binding
61 AssignmentRuleHeader arh = new AssignmentRuleHeader();
62
63 // In this sample we will look for a particular rule and if found
64 // use the id for the lead assignment. If it is not found we will
65 // instruct the call to use the current default rule. Both these
66 // values can't be used together.
67 QueryResult qr = binding.query("Select Id from AssignmentRule where Name = " +
68 "'Mass Mail Campaign' and SobjectType = 'lead'");
69 if (qr.size == 0)
70 {
71 arh.useDefaultRule = true;
72 }
73 else
74 {
75 arh.assignmentRuleId = qr.records[0].Id;
76 }
77 binding.AssignmentRuleHeaderValue = arh;
78
79 // Every operation that results in a new or updated lead will use the
80 // specified rule until the header is removed from the proxy binding
81 SaveResult[] sr = binding.create(new sObject[] { lead });
82 foreach (SaveResult s in sr)
83 {
84 if (s.success)
85 {
86 Console.WriteLine("Successfully created Lead with ID: {0}", s.id);
87 }
88 else
89 {
90 Console.WriteLine("Error creating Lead: {0}", s.errors[0].message);
91 }
92 }
93
94 // This call effectively removes the header. The next lead will be assigned
95 // to the default lead owner.
96 binding.AssignmentRuleHeaderValue = null;
97 }
98 }
99}
100