---
schema_version: "1"
id: 7c6043d9b8d97263bae7366e50e0ddc5753031263ca951959ee3d4168fb2219a
title: excludeContextTypes()
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_canvas_CanvasLifecycleHandler_excludeContextTypes.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_canvas_CanvasLifecycleHandler_excludeContextTypes.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: afc6037ab33f48e2b6a2130f9f6f310ccd7e5c083e66a0fe63a1b5efd69e2fa8
description: Lets the implementation exclude parts of the CanvasRequest context, if the application does not need it.
---
# excludeContextTypes()

Lets the implementation exclude parts of the CanvasRequest context, if the application does not need it.

## Signature

public Set<Canvas.ContextTypeEnum> excludeContextTypes()

## Return Value

Type: SET<[Canvas.ContextTypeEnum](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_canvas_ContextTypeEnum.htm "Describes context data that can be excluded from canvas app context data. You specify which context types to exclude in the excludeContextTypes() method in your CanvasLifecycleHandler implementation.")\>

This method must return null or a set of zero or more ContextTypeEnum values. Returning null enables all attributes by default. ContextTypeEnum values that can be set are:

- Canvas.ContextTypeEnum.ORGANIZATION
- Canvas.ContextTypeEnum.RECORD\_DETAIL
- Canvas.ContextTypeEnum.USER

See [ContextTypeEnum](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_enum_canvas_ContextTypeEnum.htm "Describes context data that can be excluded from canvas app context data. You specify which context types to exclude in the excludeContextTypes() method in your CanvasLifecycleHandler implementation.") for more details on these values.

## Usage

Implement this method to specify which attributes to disable in the context of the canvas app. A disabled attribute will set the associated canvas context information to null.

Disabling attributes can help improve performance by reducing the size of the signed request and canvas context. Also, disabled attributes do not need to be retrieved by Salesforce, which further improves performance.

See the [Canvas Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.264.0.platform_connect.meta/platform_connect/ "HTML (New Window)") for more information on context information in the Context object that’s provided in the CanvasRequest.

## Example

This example implementation specifies that the organization information will be disabled in the canvas context.

public Set<Canvas.ContextTypeEnum> excludeContextTypes() {
    Set<Canvas.ContextTypeEnum> excluded = new Set<Canvas.ContextTypeEnum>();
    excluded.add(Canvas.ContextTypeEnum.ORGANIZATION);
    return excluded;
}

#### See Also

- [_Canvas Developer Guide_: Filtering CanvasRequest Context Data](https://developer.salesforce.com/docs/atlas.en-us.264.0.platform_connect.meta/platform_connect/canvas_filtering_context_data.htm "Canvas Developer Guide: Filtering CanvasRequest Context
    Data - HTML (New Window)")