public Canvas.EnvironmentContext getEnvironmentContext()
Use this method to get the environment context information for your canvas app.
The following example implementation of the CanvasLifecycleHandler 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]; previousParams.put('opportunities',o); // Now, replace the parameters env.setParametersAsJSON(JSON.serialize(previousParams)); }