Templates クラス
名前空間
使用方法
Templates とそれに関連付けられているクラス Wave.TemplatesSearchOptions を使用して、CRM Analytics テンプレート情報を取得します。
例
次のコードサンプルでは、テンプレート名のリストを返すメソッドが宣言されています。
1@AuraEnabled(cacheable=true)
2public static void List<String> getTemplateNames() {
3 Map<String, Object> o = Wave.Templates.getTemplates(new Wave.TemplatesSearchOptions());
4 List<Object> templates = (List<Object>) o.get('templates');
5 List<String> names = new List<String>();
6 for (Object templateObj : templates) {
7 names.add((String) ((Map<String, Object>) templateObj.get('name'));
8 }
9 return names;
10}@AuraEnabled アノテーションを追加すると、Lightning Web コンポーネントは、Templates のメソッドに直接アクセスできます。
lwc.js ファイルの場合の例を次に示します。
1import getTemplates from '@salesforce/apex/Wave.Templates.getTemplates';
2export default class Templates extends LightningElement {
3 @wire(getTemplates, {
4 // specifying 'options' is optional
5 options: {
6 // values in TemplatesSearchOptions go here; all optional
7 type: 'app'
8 }
9 })
10 onTemplates({ data, error }) {
11 if (data) {
12 console.log('template names=' + data.templates.map(l => l.name).join(', '));
13 }
14 }
15}Templates のメソッド
Templates のメソッドは次のとおりです。
getTemplate(templateIdOrApiName)
署名
public static Map<String,Object> getTemplate(String templateIdOrApiName)
パラメーター
- templateIdOrApiName
- 型: String
- 取得するテンプレートのテンプレート ID または API 名。
戻り値
型: Map<String,Object>
テンプレート JSON 属性の名前と値のペアの対応付け。ここで名前は、オブジェクト値を含む文字列です。属性についての詳細は、TemplateRepresentation を参照してください。
例
1String templateName = (String) Wave.Templates.getTemplate(templateId).get('name');getTemplateConfig(templateIdOrApiName)
署名
public static Map<String,Object> getTemplateConfig(String templateIdOrApiName)
パラメーター
- templateIdOrApiName
- 型: String
- テンプレート設定を取得するテンプレート ID または開発者名。
戻り値
型: Map<String,Object>
テンプレート設定 JSON 属性の名前とオブジェクト値の対応付け。属性についての詳細は、TemplateConfigurationRepresentation を参照してください。
例
1Map<String, Object> templateVariables = (Map<String, Object>) Wave.Templates.getTemplateConfig(templateId).get('variables');getTemplates(options)
署名
public static Map<String,Object> getTemplates(Wave.TemplatesSearchOptions options)
パラメーター
- options
- 型: Wave.TemplatesSearchOptions
- テンプレートコレクションを絞り込むために使用する検索オプション。
戻り値
型: Map<String,Object>
テンプレート名とテンプレートオブジェクト値の対応付け。テンプレートコレクションについての詳細は、TemplateCollectionRepresentation を参照してください。
例
1Map<String,Object> templatesMap = Wave.Templates.getTemplates(new Wave.TemplatesSearchOptions());getTemplates()
署名
public static Map<String,Object> getTemplates()
戻り値
型: Map<String,Object>
テンプレート名とテンプレートオブジェクト値の対応付け。テンプレートコレクションについての詳細は、TemplateCollectionRepresentation を参照してください。
例
1Map<String,Object> templatesMap = Wave.Templates.getTemplates();