Namespace
Usage
Use Templates and its associated class Wave.TemplatesSearchOptions to get CRM Analytics template information.
Examples
This code sample declares a method that returns a list of the template names.
@AuraEnabled(cacheable=true) public static void List<String> getTemplateNames() { Map<String, Object> o = Wave.Templates.getTemplates(new Wave.TemplatesSearchOptions()); List<Object> templates = (List<Object>) o.get('templates'); List<String> names = new List<String>(); for (Object templateObj : templates) { names.add((String) ((Map<String, Object>) templateObj.get('name')); } return names; }
Adding the @AuraEnabled annotation allows Lightning Web Components to access Templates methods directly.
For example, in the lwc.js file:
import getTemplates from '@salesforce/apex/Wave.Templates.getTemplates'; export default class Templates extends LightningElement { @wire(getTemplates, { // specifying 'options' is optional options: { // values in TemplatesSearchOptions go here; all optional type: 'app' } }) onTemplates({ data, error }) { if (data) { console.log('template names=' + data.templates.map(l => l.name).join(', ')); } } }
Templates Methods
The following are methods for Templates.
getTemplate(templateIdOrApiName)
Signature
public static Map<String,Object> getTemplate(String templateIdOrApiName)
Parameters
-
templateIdOrApiName:
Type: String
The template ID or API name of the template to retrieve.
Return Value
Type: Map<String,Object>
A map of the template JSON attribute name/value pairs, where the name is a string with an object value. For attributes details, see TemplateRepresentation.
Example
String templateName = (String) Wave.Templates.getTemplate(templateId).get('name');
Here, templateId is a placeholder value.
getTemplateConfig(templateIdOrApiName)
Signature
public static Map<String,Object> getTemplateConfig(String templateIdOrApiName)
Parameters
-
templateIdOrApiName:
Type: String
The template ID or developer name to retrieve the template configuration for.
Return Value
Type: Map<String,Object>
A map of template configuration JSON attribute names and the object values. For attribute details, see TemplateConfigurationRepresentation.
Example
Map<String, Object> templateVariables = (Map<String, Object>) Wave.Templates.getTemplateConfig(templateId).get('variables');
Here, templateId is a placeholder value.
getTemplates(options)
Signature
public static Map<String,Object> getTemplates(Wave.TemplatesSearchOptions options)
Parameters
-
options:
Type: Wave.TemplatesSearchOptions
The search options to use for filtering the template collection.
Return Value
Type: Map<String,Object>
A map of template names and the template object values. For template collection details, see TemplateCollectionRepresentation.
Example
Map<String,Object> templatesMap = Wave.Templates.getTemplates(new Wave.TemplatesSearchOptions());
getTemplates()
Signature
public static Map<String,Object> getTemplates()
Return Value
Type: Map<String,Object>
A map of template names and the template object values. For template collection details, see TemplateCollectionRepresentation.
Example
Map<String,Object> templatesMap = Wave.Templates.getTemplates();