---
schema_version: "1"
id: 6feeece733bdb0feec05ec20d62c7f3bcf6aeda083a90a1be8aec84e2748966a
title: TaskRelation
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/sforce_api_objects_taskrelation.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_taskrelation.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 490e017181d528e8a662ce4ef4464ca550a872fdda4c309245aad20fcba72eca
description: 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

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](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/field_types.htm#i1435616).





 |
| 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](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/field_types.htm#i1435616).





 |
| TaskId | 

Type

reference

Properties

Create, Filter, Group, Sort

Description

Represents the ID of the associated Task.

For information on IDs, see [ID Field Type](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/field_types.htm#i1435616).





 |

## Usage

See contacts associated with a task

public void queryWhosOfTaskSample() {
     String soqlQuery = "SELECT Id, Subject, (SELECT RelationId, Relation.Name, IsWhat from TaskRelations WHERE isWhat = false) FROM Task WHERE Id = '00T x0000005OKEN'";
    QueryResult qResult = null;
    try {
        qResult = connection.query(soqlQuery);
        TaskRelation relation1 = (TaskRelation)qResult.getRecords()\[0\].getTaskRelations().getRecords()\[0\];
    }catch (ConnectionException ce) {
        ce.printStackTrace();
     }
 }

## Associated Objects

This object has the following associated objects. If the API version isn’t specified, they’re available in the same API versions as this object. Otherwise, they’re available in the specified API version and later.

[TaskRelationChangeEvent](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_associated_objects_change_event.htm "A ChangeEvent object is available for each object that supports Change Data Capture. You can subscribe to a stream of change events using Change Data Capture to receive data tied to record changes in Salesforce. Changes include record creation, updates to an existing record, deletion of a record, and undeletion of a record. A change event isn’t a Salesforce object—it doesn’t support CRUD operations or queries. It’s included in the object reference so you can discover which Salesforce objects support change events.") (API version 44.0)

Change events are available for the object.

#### See Also

- [Task](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_task.htm "Represents a business activity such as making a phone call or other to-do items. In the user interface, Task and Event records are collectively referred to as activities.")
- [TaskWhoRelation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_taskwhorelation.htm "Represents the relationship between a task and a lead or contacts. This object is available in API version 29.0 and later.")