Lead
サポートされているコール
create()、delete()、describeLayout()、describeSObjects()、getDeleted()、getUpdated()、merge()、query()、retrieve()、search()、undelete()、update()、upsert()
項目
| 項目 | 詳細 |
|---|---|
| Address |
|
| AnnualRevenue |
|
| City |
|
| CleanStatus |
|
| Company |
|
| CompanyDunsNumber | |
| ConnectionReceivedId | |
| ConnectionSentId | |
| ConvertedAccountId |
|
| ConvertedContactId |
|
| ConvertedDate |
|
| ConvertedOpportunityId |
|
| Country |
|
| CountryCode |
|
| CurrencyIsoCode |
|
| Description |
|
| Division |
|
|
|
| EmailBouncedDate |
|
| EmailBouncedReason |
|
| Fax |
|
| FirstName |
|
| HasOptedOutOfEmail |
|
| GeocodeAccuracy |
|
| Industry |
|
| IsConverted |
|
| IsDeleted |
|
| IsUnreadByOwner |
|
| Jigsaw |
|
| LastActivityDate |
|
| LastName |
|
| LastReferencedDate |
|
| LastViewedDate |
|
| 緯度 | |
| 経度 | |
| LeadSource |
|
| MasterRecordId |
|
| MiddleName |
|
| MobilePhone |
|
| Name |
|
| NumberOfEmployees |
|
| OwnerId |
|
| PartnerAccountId | |
| Phone |
|
| PhotoUrl |
|
| PostalCode |
|
| Rating |
|
| RecordTypeId |
|
| Salutation |
|
| State |
|
| StateCode |
|
| Status |
|
| Street |
|
| Suffix |
|
| Title |
|
| Website |
|
変換済みのリード
リードが Account、Contact、Opportunity (オプション) に変換されたことを示す特別な状況があります。クライアントアプリケーションは、convertLead() コールを使用してリードを変換することができます。また、ユーザはユーザインターフェースを使用してリードを変換することもできます。リードが変換されると、参照のみになります。変換されたリードは、更新または削除できません。ただし、変換されたリードレコードをクエリすることはできます。
リードには、変換された状況を示すいくつかの項目があります。これらの項目は、ユーザインターフェースでリードを変換する場合に設定されます。
- ConvertedAccountId
- ConvertedContactId
- ConvertedDate
- ConvertedOpportunityId
- IsConverted
- Status
未読のリード
リードには、リード所有者が参照していないまたは編集していないことを示す特別な状況があります。ユーザインターフェースでは、ユーザが割り当てられているがまだ処理されていないリードを知っておくことは役に立ちます。リード所有者がまだリードを参照も編集もしていない場合、IsUnreadByOwner 項目が true になります。リード所有者がリードを少なくとも一度は参照または編集している場合は false となります。
リード状況選択リスト
Status の値は、ユーザインターフェースで定義されているように、リード状況選択リストの変換された状況または変換されていない状況に対応します。選択リストでリードの状況値を取得するには、クライアントアプリケーションは、LeadStatus をクエリできます。
API によって、Status をリードが変換済みであることを示す状況値のいずれかに変更して、リードを変換することはできません。評価済みリードを取引先、取引先責任者、商談に変換する際に、リードに対して、変換済みであることを示す状況のタイプを 1 つ選択できます。こうしたタイプを割り当てられたリードは、レポートに含めることはできますが、[リード] タブには表示されなくなります。
使用方法
リードを更新する、または convertLead() を使用して変換するには、リードに対する「編集」権限でクライアントアプリケーションにログインしている必要があります。
リードを作成、更新、または更新/挿入すると、クライアントアプリケーションは、ユーザインターフェースで設定された割り当てルールに基づいて、リードを 1 つ以上の User レコードに自動的に割り当てることができます。
この機能を使用するために、クライアントアプリケーションは、create または update で使用する AssignmentRuleHeader に次のオプションのいずれか (両方ではない) を設定する必要があります。
Java のサンプル
次の Java のサンプルでは、新しく作成されたリードを自動的にどのように割り当てるかを示しています。
1package wsc;
2
3import com.sforce.soap.enterprise.Connector;
4import com.sforce.soap.enterprise.EnterpriseConnection;
5import com.sforce.ws.ConnectionException;
6import com.sforce.ws.ConnectorConfig;
7import com.sforce.soap.enterprise.sobject.Lead;
8import com.sforce.soap.enterprise.QueryResult;
9import com.sforce.soap.enterprise.SaveResult;
10import com.sforce.soap.enterprise.sobject.SObject;
11
12public class LeadAssignment {
13
14 static final String USERNAME = "REPLACE USER NAME";
15 static final String PASSWORD = "REPLACE PASSWORD";
16 static EnterpriseConnection connection;
17
18 static LeadAssignment _leadAssignment;
19
20 // Main
21 public static void main(String[] args)
22 {
23 // Establish connection and login
24 ConnectorConfig config = new ConnectorConfig();
25 config.setUsername(USERNAME);
26 config.setPassword(PASSWORD);
27 try {
28 connection = Connector.newConnection(config);
29 System.out.println("Logged in, endpoint: " + config.getAuthEndpoint());
30 } catch (ConnectionException e1) {
31 e1.printStackTrace();
32 }
33
34 // Create lead
35 _leadAssignment = new LeadAssignment();
36 try {
37 _leadAssignment.CreateLead();
38 } catch (Exception e) {
39 e.printStackTrace();
40 }
41
42 // Logout
43 try {
44 connection.logout();
45 System.out.println("Logged out");
46 } catch (ConnectionException ce) {
47 ce.printStackTrace();
48 }
49 }
50
51 public void CreateLead() throws ConnectionException
52 {
53 // Create a new Lead and assign various properties
54 Lead lead = new Lead();
55
56 lead.setFirstName("Joe");
57 lead.setLastName("Smith");
58 lead.setCompany("ABC Corporation");
59 lead.setLeadSource("API");
60 // The lead assignment rule will assign any new leads that
61 // have "API" as the LeadSource to a particular user
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. You can't use
66 // both of these values together.
67 QueryResult qr = connection.query("SELECT Id FROM AssignmentRule WHERE Name = " +
68 "'Mass Mail Campaign' AND SobjectType = 'Lead'");
69 if (qr.getSize() == 0) {
70 connection.setAssignmentRuleHeader(null, true);
71 } else {
72 connection.setAssignmentRuleHeader(qr.getRecords()[0].getId(), false);
73 }
74
75 // Every operation that results in a new or updated lead will
76 // use the specified rule until the header is removed from the
77 // connection.
78 SaveResult[] sr = connection.create(new SObject[] {lead});
79 for (int i=0;i<sr.length;i++) {
80 if (sr[i].isSuccess()) {
81 System.out.println("Successfully created lead with id of: " +
82 sr[i].getId() + ".");
83 } else {
84 System.out.println("Error creating lead: " +
85 sr[i].getErrors()[0].getMessage());
86 }
87 }
88
89 // This call effectively removes the header, the next lead will
90 // be assigned to the default lead owner.
91 connection.clearAssignmentRuleHeader();
92 }
93}C# のサンプル
次の C# のサンプルでは、新しく作成されたリードを自動的にどのように割り当てるかを示しています。
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using System.ServiceModel;
7using LeadSample.sforce;
8
9namespace LeadSample
10{
11 class LeadAssignment
12 {
13 private static SoapClient client;
14 private static SoapClient apiClient;
15 private static SessionHeader header;
16 private static LoginResult loginResult;
17 private static readonly string Username = "REPLACE USERNAME";
18 private static readonly string Password = "REPLACE PASSWORD AND SECURITY TOKEN";
19
20 // Create the proxy binding and login
21 private LeadAssignment()
22 {
23 client = new SoapClient();
24
25 try
26 {
27 loginResult = client.login(null, Username, Password);
28 }
29 catch (Exception e)
30 {
31 Console.WriteLine("Unexpected login error: " + e.Message);
32 Console.WriteLine(e.StackTrace);
33 return;
34 }
35 // Access API endpoint and create new client
36 header = new SessionHeader();
37 header.sessionId = loginResult.sessionId;
38 apiClient = new SoapClient("Soap", loginResult.serverUrl);
39 }
40
41 [STAThread]
42 static void Main(string[] args)
43 {
44 LeadAssignment leadAssignment = new LeadAssignment();
45 try
46 {
47 leadAssignment.CreateLead();
48 }
49 catch (Exception e)
50 {
51 Console.WriteLine(e.Message);
52 Console.WriteLine(e.StackTrace);
53 Console.WriteLine(e.InnerException);
54 }
55 // logout
56 client.logout(header);
57 }
58
59 public void CreateLead()
60 {
61 // Create a new Lead and assign various properties
62 Lead lead = new Lead();
63
64 lead.FirstName = "John";
65 lead.LastName = "Brown";
66 lead.Company = "ABC Corporation";
67 lead.LeadSource = "Advertisement";
68 // Setting the lead source for a pre-existing lead assignment rule. This
69 // rule was created outside of this sample and will assign any new leads
70 // that have "Advertisement" as the LeadSource to a particular user.
71
72 // Create the assignment rule header and add it to the proxy binding
73 AssignmentRuleHeader arh = new AssignmentRuleHeader();
74
75 // In this sample we will look for a particular rule and if found
76 // use the id for the lead assignment. If it is not found we will
77 // instruct the call to use the current default rule. Both these
78 // values can't be used together.
79 QueryResult qr = null;
80 string query = "SELECT Id FROM AssignmentRule WHERE Name = " +
81 "'Mass Mail Campaign' AND SobjectType = 'Lead'";
82 try
83 {
84 LimitInfo[] limitArray = apiClient.query(
85 header, // sessionheader
86 null, // queryoptions
87 null, // mruheader
88 null, // packageversionheader
89 query, // SOQL query
90 out qr);
91 }
92 catch (Exception e)
93 {
94 Console.WriteLine("Unexpected query error: " + e.Message);
95 Console.WriteLine(e.StackTrace);
96 }
97 if (qr.size == 0)
98 {
99 arh.useDefaultRule = true;
100 }
101 else
102 {
103 arh.assignmentRuleId = qr.records[0].Id;
104 }
105
106 // Create the lead using our Assignment Rule header
107 LimitInfo[] li;
108 SaveResult[] sr;
109 apiClient.create(
110 header, // sessionheader
111 arh, // assignmentruleheader
112 null, // mruheader
113 null, // allowfieldtrunctionheader
114 null, // disablefeedtrackingheader
115 null, // streamingenabledheader
116 null, // allornoneheader
117 null, // duplicateruleheader
118 null, // localeoptions
119 null, // debuggingheader
120 null, // packageversionheader
121 null, // emailheader
122 new sObject[] { lead },
123 out li,
124 out sr);
125 foreach (SaveResult s in sr)
126 {
127 if (s.success)
128 {
129 Console.WriteLine("Successfully created Lead with ID: {0}", s.id);
130 }
131 else
132 {
133 Console.WriteLine("Error creating Lead: {0}", s.errors[0].message);
134 }
135 }
136 }
137 }
138}