WaveTemplateConfigurationModifier Apex Examples

Examples include setting computed values for questions, hiding a question, managing enum values, working with array type variables, and more.

Example 

Create your class:

1public class ExampleWaveTemplateConfigurationModifier
2    extends wavetemplate.WaveTemplateConfigurationModifier
3{
4    public override void onConfigurationRetrieval(wavetemplate.WaveTemplateInfo template)
5    {
6        // Method implementation
7    }
8}

Example 

Set the computed value for one of the questions:

1public override void onConfigurationRetrieval(wavetemplate.WaveTemplateInfo template)
2{
3    Map<string, wavetemplate.VariableDefinition> variables = template.getVariables();
4    variables.get('Has_Product').setComputedValue('No');
5}

Example 

Hide one of the questions:

1public override void onConfigurationRetrieval(wavetemplate.WaveTemplateInfo template)
2{
3    template.getUI().getPages().get(0).getVariables()
4        .get('Has_Product').setVisibility(wavetemplate.VisibilityEnum.Hidden);
5}

Example 

Remove an enum value from the dropdown list box using the specified array index:

1public override void onConfigurationRetrieval(wavetemplate.WaveTemplateInfo template)
2{
3    Map<string, wavetemplate.VariableDefinition> variables = template.getVariables();
4    wavetemplate.VariableDefinition hasProduct = variables.get('Has_Product');
5    List<object> enums = hasProduct.getVariableType().getEnums();
6    enums.remove(1);
7    hasProduct.getVariableType().setEnums(enums);
8}

Example 

Populate the enum values in the dropdown list box (StringType variable):

1public override void onConfigurationRetrieval(wavetemplate.WaveTemplateInfo template)
2{
3    Map<string, wavetemplate.VariableDefinition> variables = template.getVariables();
4    wavetemplate.VariableDefinition caseRecordTypes =
5        variables.get('IncludeCaseRecordTypes');
6    List<object> enums = caseRecordTypes.getVariableType().getEnums();
7    RecordType [] results = [SELECT Name FROM RecordType where sobjectType = 'Case'];
8    for (RecordType record : results){
9        //adds the record type names to the drop down list
10        enums.add((string)record.get('Name'));
11    }
12    caseRecordTypes.getVariableType().setEnums(enums);
13}

Example 

Given the following ArrayType variable:

1"OpptyRecordType":
2{
3    "label": "Select OpptyRecordTypes that you want to bring in to Salesforce",
4    "description": "Choose OpptyRecordTypes that you want to bring in to Salesforce.",
5    "required": false,
6    "variableType": {
7        "type": "ArrayType",
8        "itemsType": {
9            "type": "StringType",
10            "enums": ["Test", "Test2"]
11        }
12    }
13}

Add more values to the ArrayType variable enums:

1Map<string, wavetemplate.VariableDefinition> variables = template.getVariables();
2    wavetemplate.VariableDefinition enumsTest = variables.get('OpptyRecordType');
3    List<object> enums = enumsTest.getVariableType().getItemsType().getEnums();
4    //create an empty list if you want to overwrite the original enums.
5    RecordType [] results = [SELECT Name FROM RecordType where sobjectType
6        = 'Opportunity' AND IsActive = true];
7    for ( RecordType record : results ) {
8        enums.add((string)record.get('Name'));
9    }
10    enumsTest.getVariableType().getItemsType().setEnums(enums);

Example 

Reduce the possible answers via the excludes:

1public override void onConfigurationRetrieval(wavetemplate.WaveTemplateInfo template)
2{
3    Map<string, wavetemplate.VariableDefinition> variables = template.getVariables();
4    wavetemplate.VariableDefinition hasProduct = variables.get('Has_Product');
5    Set<string> excludes = new Set<string>();
6    excludes.add('Foo');
7    excludes.add('Bar');
8    hasProduct.setExcludes(excludes);
9}

Example 

Set a variable answer before the app creates. Updating answers overwrites any value the user selected in the wizard:

1public override void beforeAppCreate(wavetemplate.WaveTemplateInfo waveTemplate,
2    wavetemplate.Answers answers)
3{
4    answers.put('Has_Product', 'No');
5}

Example 

Set a variable answer before the app updates. Updating answers overwrites any value the user selected in the wizard:

1public override void beforeAppUpdate(wavetemplate.WaveTemplateInfo waveTemplate,
2    String previousAppVersion, wavetemplate.Answers answers)
3{
4    answers.put('Has_Product', 'Yes');
5}