---
schema_version: "1"
id: b6c9601d0878673f056fce847cc18421bf4ef9757dbb5e7ff33b834385cd54ad
title: getEnvironmentContext()
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_canvas_RenderContext_getEnvironmentContext.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_canvas_RenderContext_getEnvironmentContext.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: ea203a3dfd6372071f0abb0f495e49bc929463f4d34db4b081fd21ad70c0e33f
description: Retrieves the environment context information.
---
# getEnvironmentContext()

Retrieves the environment context information.

## Signature

public Canvas.EnvironmentContext getEnvironmentContext()

## Return Value

Type: [Canvas.EnvironmentContext](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_canvas_EnvironmentContext.htm "Use this interface to retrieve environment context information, such as the app display location or the configuration parameters.")

## Usage

Use this method to get the environment context information for your canvas app.

## Example

The following example implementation of the [CanvasLifecycleHandler](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_canvas_CanvasLifecycleHandler.htm "Implement this interface to control context information and add custom behavior during the application render phase.") onRender() method uses the provided RenderContext to retrieve the environment context information and then modifies the custom parameters.

public void onRender(Canvas.RenderContext renderContext) {
   Canvas.EnvironmentContext env = 
        renderContext.getEnvironmentContext();
        
    // Retrieve the custom params
    Map<String, Object\> previousParams = (Map<String, Object\>)
          JSON.deserializeUntyped(env.getParametersAsJSON());

    previousParams.put('param1',1);
    previousParams.put('param2',3.14159);

    ...

    // Now, add in some opportunity record IDs
    Opportunity\[\] o = \[SELECT Id, name FROM opportunity WITH USER\_MODE\];
    previousParams.put('opportunities',o);

    // Now, replace the parameters
    env.setParametersAsJSON(JSON.serialize(previousParams));
}