Newer Version Available

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

ReportType

Represents the metadata associated with a custom report type. Custom report types allow you to build a framework from which users can create and customize reports. For more information, see “Set Up a Custom Report Type” in the Salesforce online help.

This type extends the Metadata metadata type and inherits its fullName field.

Declarative Metadata File Suffix and Directory Location

The file suffix is .reportType for the custom report type definition. There is one file per custom report type. Report types are stored in the reportTypes directory of the corresponding package directory.

Version

Custom report types are available in API version 14.0 and later.

Fields

Field Name Field Type Description
autogenerated boolean Indicates that the report type was automatically generated when historical trending was enabled for an entity.

Available in API version 29 and later.

baseObject string Required. The primary object for the custom report type, for example, Account. All objects, including custom and external objects, are supported. You cannot edit this field after initial creation.

Support for external objects is available in API version 38.0 and later.

category ReportTypeCategory (enumeration of type string) Required. This field controls the category for the report. The valid values are:
  • accounts
  • opportunities
  • forecasts
  • cases
  • leads
  • campaigns
  • activities
  • busop
  • products
  • admin
  • territory
  • territory2 (This value is available in API version 31.0 and later.)
  • usage_entitlement
  • wdc (This value is available in API version 29.0 and later.)
  • calibration (This value is available in API version 29.0 and later.)
  • other
  • content
deployed boolean Required. Indicates whether the report type is available to users (true) or whether it's still in development (false).
description string The description of the custom report type.
fullName string The report type developer name used as a unique identifier for API access. The fullName can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
join ObjectRelationship The object joined to the baseObject. For example, Contacts may be joined to the primary Accounts object.
label string Required. The report type label.
sections ReportLayoutSection[] The groups of columns available for the report type. Though columns are not strictly required, a report without columns is not very useful.

ObjectRelationship

ObjectRelationship represents a join to another object. For more information, see “Add Child Objects To Your Custom Report Type” in the Salesforce online help.

Field Name Field Type Description
join ObjectRelationship This field is a recursive reference that allows you to join more than two objects. A maximum of four objects can be joined in a custom report type. When more than two objects are joined, an inner join is not allowed if there has been an outer join earlier in the join sequence. The baseObject is first joined to the object specified in relationship; the resulting data set is then joined with any objects specified in this field.
outerJoin boolean Required. Indicates whether this is an outer join (true) or not (false). An outer join returns a row even if the joined table does not contain a matching value in the join column.
relationship string Required. The object joined to the primary object; for example, Contacts.

ReportLayoutSection

ReportLayoutSection represents a group of columns used in the custom report type.

Field Name Field Type Description
columns ReportTypeColumn[] The list of columns projected from the query, defined by this custom report type.
masterLabel string Required. The label for this group of columns in the report wizard.

ReportTypeColumn

ReportTypeColumn represents a column in the custom report type.

Field Name Field Type Description
checkedByDefault boolean Required. Indicates whether this column is selected be default (true) or not (false).
displayNameOverride string A customized column name, if desired.
field string Required. The field name associated with the report column.
table string Required. The table associated with the field; for example, Account.

Declarative Metadata Sample Definition

The definition of a custom report type is shown below. Account is joined to Contacts and the resulting data set is joined with Assets.

1<?xml version="1.0" encoding="UTF-8"?>
2<ReportType xmlns="http://soap.sforce.com/2006/04/metadata">
3    <baseObject>Account</baseObject>
4    <category>accounts</category>
5    <deployed>true</deployed>
6    <description>Account linked to Contacts and Assets</description>
7    <join>
8        <join>
9            <outerJoin>false</outerJoin>
10            <relationship>Assets</relationship>
11        </join>
12        <outerJoin>false</outerJoin>
13        <relationship>Contacts</relationship>
14    </join>
15    <label>Account Contacts and Assets</label>
16    <sections>
17        <columns>
18            <checkedByDefault>true</checkedByDefault>
19            <field>obj_lookup__c.Id</field>
20            <table>Account</table>
21        </columns>
22        <columns>
23            <checkedByDefault>false</checkedByDefault>
24            <field>obj_lookup__c.Name</field>
25            <table>Account</table>
26        </columns>
27        <columns>
28            <checkedByDefault>false</checkedByDefault>
29            <field>Opportunity__c.Amount</field>
30            <table>Account</table>
31        </columns>
32        <columns>
33            <checkedByDefault>false</checkedByDefault>
34            <field>Owner.IsActive</field>
35            <table>Account</table>
36        </columns>
37        <masterLabel>Accounts</masterLabel>
38    </sections>
39    <sections>
40        <columns>
41            <checkedByDefault>false</checkedByDefault>
42            <field>Owner.Email</field>
43            <table>Account.Contacts</table>
44        </columns>
45        <columns>
46            <checkedByDefault>false</checkedByDefault>
47            <field>byr__c</field>
48            <table>Account.Contacts</table>
49        </columns>
50        <columns>
51            <checkedByDefault>true</checkedByDefault>
52            <field>ReportsTo.CreatedBy.Contact.Owner.MobilePhone</field>
53            <table>Account.Contacts</table>
54        </columns>
55        <masterLabel>Contacts</masterLabel>
56    </sections>
57</ReportType>

Usage

The custom report type refers to fields by using their API names. For a historical field (one that has trackTrending set to true) the API name includes hst, such as Field2__c_hst.

1<sections>
2    <columns>
3        <checkedByDefault>false</checkedByDefault>
4        <field>Field2__c_hst</field>
5        <table>CustomTrendedObject__c.CustomTrendedObject__c_hst</table>
6    </columns>
7    <masterLabel>History</masterLabel>
8</sections>

For more information, see trackTrending.