Newer Version Available
OwnerChangeOptions
Specifies ownership of attachments, notes, and open activities when transfers occur.
Fields
| Element Name | Type | Description |
|---|---|---|
| transferAttachments | boolean |
If true, the record’s notes, attachments, and Google Docs are transferred to the new record owner. If false, the original record owner retains ownership. The default is true. |
| transferOpenActivites | boolean |
If true, the record’s open activities are transferred to the new record owner. If false, the original record owner retains ownership. The default is true. |
Sample Code—Java
This sample creates an account, a note and task for the account, and sets the owner change options so that the note and task are transferred to the new owner.
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}