Newer Version Available
Task
Supported Calls
create(), delete(), describeLayout(), describeSObjects(), getDeleted(), getUpdated(), query(), retrieve(), search(), undelete(), update(), upsert()
Fields
| Field | Field Type |
|---|---|
| AccountId |
|
| ActivityDate |
|
| CallDisposition |
|
| CallDurationInSeconds |
|
| CallObject |
|
| CallType |
|
| ConnectionReceivedId |
|
| ConnectionSentId |
|
| Description |
|
| IsArchived |
|
| IsClosed |
|
| IsHighPriority |
|
| IsRecurrence |
|
| IsReminderSet |
|
| IsVisibleInSelfService |
|
| OwnerId |
|
| Priority |
|
| RecurrenceActivityId |
|
| RecurrenceDayOfMonth |
|
| RecurrenceDayOfWeekMask |
|
| RecurrenceEndDateOnly |
|
| RecurrenceInstance |
|
| RecurrenceInterval |
|
| RecurrenceMonthOfYear |
|
| RecurrenceRegeneratedType |
|
| RecurrenceStartDateOnly |
|
| RecurrenceTimeZoneSidKey |
|
| RecurrenceType |
|
| ReminderDateTime |
|
| Status |
|
| Subject |
|
| TaskSubtype | |
| TaskWhoIds |
|
| Type |
|
| WhatCount |
|
| WhatId |
|
| WhoCount |
|
| WhoId |
|
Usage
- Recurring tasks are available in API version 16.0 and later.
- After a task is created, it can’t be changed from recurring to nonrecurring or vice versa.
- When you delete a recurring task series through the API, all open and closed task occurrences in the series are removed. However, when you delete a recurring task series through the user interface, only open tasks occurrences (IsClosed is false) in the series are removed.
- If IsRecurrence is true, then RecurrenceStartDateOnly, RecurrenceEndDateOnly, RecurrenceType, and any properties associated with the given recurrence type (see the following table) must be populated.
- When you change the RecurrenceStartDateOnly field or the recurrence pattern, all open tasks occurrences in the series are deleted and new open task occurrences are created based on the new recurrence pattern. The recurrence pattern is determined by the following fields: RecurrenceType, RecurrenceTimeZoneSidKey, RecurrenceInterval, RecurrenceDayOfWeekMask, RecurrenceDayOfMonth, RecurrenceInstance, and RecurrenceMonthOfYear.
- When you change the value of RecurrenceEndDateOnly to an earlier date (for example, from January 20th to January 10th), all open task occurrences in the series with the ActivityDate value greater than the new end date value are deleted. Other open and closed task occurrences in the series are not affected.
- When you change the value of RecurrenceEndDateOnly to a later date (for example, from January 10th to January 20th), new task occurrences are created up to the new end date. Existing open and closed tasks in the series are not affected.
The following table describes the usage of recurrence fields. Each recurrence type must have all of its properties set. All unused properties must be set to null.
| RecurrenceType Value | Properties | Example Pattern |
|---|---|---|
| RecursDaily | RecurrenceInterval | Every second day |
| RecursEveryWeekday | RecurrenceDayOfWeekMask | Every weekday - can’t be Saturday or Sunday |
| RecursMonthly | RecurrenceDayOfMonth RecurrenceInterval | Every second month, on the third day of the month |
| RecursMonthlyNth | RecurrenceInterval RecurrenceInstance RecurrenceDayOfWeekMask | Every second month, on the last Friday of the month |
| RecursWeekly | RecurrenceInterval RecurrenceDayOfWeekMask | Every three weeks on Wednesday and Friday |
| RecursYearly | RecurrenceDayOfMonth RecurrenceMonthOfYear | Every March on the twenty-sixth day of the month |
| RecursYearlyNth | RecurrenceDayOfWeekMask RecurrenceInstanceRecurrenceMonthOfYear | The first Saturday in every October |
- JunctionIdList
-
The JunctionIdList field is now implemented in the Event and Task objects. With a single API call, it’s easy to create many-to-many relationships between the Event or Task object with contacts, leads, or users.
To create a Task with related Contacts without JunctionIdList, you first have to create the task, then use the returned task ID to create the TaskRelation records. If the TaskRelation save call fails, error handling is your responsibility because the task has already been committed to the database.1public void createTasksOld(Contact[] contacts) { 2 Task task = new Task(); 3 task.setSubject("New Task"); 4 SaveResult[] results = null; 5 try { 6 results = connection.create(new Task[] { 7 task 8 }); 9 if (results[0].isSuccess()) { 10 TaskRelation[] relations = new TaskRelation[contacts.size()]; 11 for (int i = 0; i < contacts.length; i++) { 12 relations[i] = new TaskRelation(); 13 relations[i].setTaskId(results[0].getID()); 14 resltsion[i].setRelationId(contacts[i].getID()); 15 } 16 results = connection.create(relations); 17 } 18 } catch (ConnectionException ce) { 19 ce.printStackTrace(); 20 } 21} - To create a task using JuncionIdList, IDs are pulled from the
related contacts and both the task and the TaskRelation records
are created in one API call. If the TaskRelation fails, the task
is rolled back because it’s all done in a single API
call.
1public void createTaskNew(Contact[] contacts) { 2 String[] contactIds = new String[contacts.size()]; 3 for (int i = 0; i < contacts.size(); i++) { 4 contactIds[i] = contacts[i].getID(); 5 } 6 Task task = new Task(); 7 task.setSubject("New Task"); 8 task.setTaskWhoIds(contactIds); 9 SaveResult[] results = null; 10 try { 11 results = connection.create(new Task[] { 12 task 13 }); 14 } catch (ConnectionException ce) { 15 ce.printStackTrace(); 16 } 17}