OwnerChangeOptions
移行が行われた場合に、添付ファイル、メモ、および活動予定の所有者を指定します。
項目
サンプルコード — Java
このサンプルでは、取引先と、取引先のメモおよび ToDo を作成し、メモと ToDo が新しい所有者に移行されるように所有者変更オプションを設定します。
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17public void ownerChangeOptionsHeaderSample() {
18
19 // Create account. Accounts don't transfer activities, notes, or attachments by default
20
21 Account account = new Account();
22 account.setName("Account");
23 com.sforce.soap.enterprise.SaveResult[] sr = connection.create(new com.sforce.soap.enterprise.sobject.SObject[] { account } );
24 String accountId = null;
25
26 if(sr[0].isSuccess()) {
27 System.out.println("Successfully saved the account");
28 accountId = sr[0].getId();
29
30 // Create a note and a task for the account
31
32 Note note = new Note();
33 note.setTitle("Note Title");
34 note.setBody("Note Body");
35 note.setParentId(accountId);
36
37 Task task = new Task();
38 task.setWhatId(accountId);
39
40 sr = connection.create(new com.sforce.soap.enterprise.sobject.SObject[] { note, task } );
41
42 if(sr[0].isSuccess()) {
43 System.out.println("Successfully saved the note and task");
44
45 com.sforce.soap.enterprise.QueryResult qr = connection.query("SELECT Id FROM User WHERE FirstName = 'Jane' AND LastName = 'Doe'");
46 String newOwnerId = qr.getRecords()[0].getId();
47 account.setId(accountId);
48 account.setOwnerId(newOwnerId);
49
50 // Set owner change options so account's child note & task transfer to new owner
51
52 connection.setOwnerChangeOptions(true, true);
53 connection.update(new com.sforce.soap.enterprise.sobject.SObject[] { account } );
54
55 // The account, account's note, & task should be transferred to the new owner.
56 }
57
58 } else {
59 System.out.println("Account save failed: " + sr[0].getErrors().toString());
60 }
61}