No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
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");public void ownerChangeOptionsHeaderSample() {
2
3 // Create account. Accounts don't transfer activities, notes, or attachments by default
4
5 Account account = new Account();
6 account.setName("Account");
7 com.sforce.soap.enterprise.SaveResult[] sr = connection.create(new com.sforce.soap.enterprise.sobject.SObject[] { account } );
8 String accountId = null;
9
10 if(sr[0].isSuccess()) {
11 System.out.println("Successfully saved the account");
12 accountId = sr[0].getId();
13
14 // Create a note and a task for the account
15
16 Note note = new Note();
17 note.setTitle("Note Title");
18 note.setBody("Note Body");
19 note.setParentId(accountId);
20
21 Task task = new Task();
22 task.setWhatId(accountId);
23
24 sr = connection.create(new com.sforce.soap.enterprise.sobject.SObject[] { note, task } );
25
26 if(sr[0].isSuccess()) {
27 System.out.println("Successfully saved the note and task");
28
29 com.sforce.soap.enterprise.QueryResult qr = connection.query("SELECT Id FROM User WHERE FirstName = 'Jane' AND LastName = 'Doe'");
30 String newOwnerId = qr.getRecords()[0].getId();
31 account.setId(accountId);
32 account.setOwnerId(newOwnerId);
33
34 // Set owner change options so account's child note & task transfer to new owner
35
36 connection.setOwnerChangeOptions(true, true);
37 connection.update(new com.sforce.soap.enterprise.sobject.SObject[] { account } );
38
39 // The account, account's note, & task should be transferred to the new owner.
40 }
41
42 } else {
43 System.out.println("Account save failed: " + sr[0].getErrors().toString());
44 }
45}