Newer Version Available

This content describes an older version of this product. View Latest

TaskRelation

Represents the relationship between a task and a lead, contacts, and other objects related to the task. If Shared Activities is enabled, this object doesn’t support triggers, workflow, or data validation rules. This object is available in API version 24.0 and later.

TaskRelation is only available if you’ve enabled Shared Activities in your organization.

TaskRelation allows the following relationships:

  • A task can be related to one lead or up to 50 contacts.
  • A task can also be related to one account, asset, campaign, case, contract, opportunity, product, solution, or custom object.

Supported Calls

create()delete()describeSObjects()getDeleted()getUpdated()query()queryAll(), retrieve()

Fields

Field Name Details
AccountId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
Indicates the Account ID of the relation.

For information on IDs, see ID Field Type.

IsDeleted
Type
boolean
Properties
Defaulted on create, Filter, Group, Sort
Description
Indicates whether a task has been deleted; label is Deleted. When a TaskRelation record is deleted, it isn’t moved to the Recycle Bin and can’t be undeleted, unless the record was cascade-deleted when the parent object was deleted. Don’t use the IsDeleted field to detect deleted records in SOQL queries or queryAll() calls on directly deleted relation records. Instead, use the call getDeleted().
IsWhat
Type
boolean
Properties
Create, Defaulted on create, Filter, Group, Sort
Description
Indicates whether the relation is an Account, Opportunity, Campaign, Case, other standard object, or a custom object. Value is false if RelationId is a contact or lead and true otherwise.
RelationId
Type
reference
Properties
Create, Filter, Group, Sort
Description
Indicates the WhatId or WhoId in the relationship. For more information, see Task.

For information on IDs, see ID Field Type.

TaskId
Type
reference
Properties
Create, Filter, Group, Sort
Description
Represents the ID of the associated Task.

For information on IDs, see ID Field Type.

Usage

See contacts associated with a task
1public void queryWhosOfTaskSample() {
2     String soqlQuery = "SELECT Id, Subject, (SELECT RelationId, Relation.Name, IsWhat from TaskRelations WHERE isWhat = false) FROM Task WHERE Id = '00T x0000005OKEN'";
3    QueryResult qResult = null;
4    try {
5        qResult = connection.query(soqlQuery);
6        TaskRelation relation1 = (TaskRelation)qResult.getRecords()[0].getTaskRelations().getRecords()[0];
7    }catch (ConnectionException ce) {
8        ce.printStackTrace();
9     }
10 }