この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

Newer Version Available

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

getEnvironmentContext()

環境のコンテキスト情報を取得します。

署名

public Canvas.EnvironmentContext getEnvironmentContext()

使用方法

このメソッドを使用して、キャンバスアプリケーションの環境コンテキスト情報を取得します。

CanvasLifecycleHandler onRender() メソッドの次の実装例では、指定された RenderContext を使用して、環境コンテキスト情報を取得し、カスタムパラメータを変更します。

1public void onRender(Canvas.RenderContext renderContext) {
2   Canvas.EnvironmentContext env = 
3        renderContext.getEnvironmentContext();
4        
5    // Retrieve the custom params
6    Map<String, Object> previousParams = (Map<String, Object>)
7          JSON.deserializeUntyped(env.getParametersAsJSON());
8
9    previousParams.put('param1',1);
10    previousParams.put('param2',3.14159);
11
12    ...
13
14    // Now, add in some opportunity record IDs
15    Opportunity[] o = [select id, name from opportunity];
16    previousParams.put('opportunities',o);
17
18    // Now, replace the parameters
19    env.setParametersAsJSON(JSON.serialize(previousParams));
20}