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:

public class ExampleWaveTemplateConfigurationModifier
    extends wavetemplate.WaveTemplateConfigurationModifier
{
    public override void onConfigurationRetrieval(wavetemplate.WaveTemplateInfo template)
    {
        // Method implementation
    }
}

Example

Set the computed value for one of the questions:

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

Example

Hide one of the questions:

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

Example

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

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

Example

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

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

Example

Given the following ArrayType variable:

"OpptyRecordType":
{
    "label": "Select OpptyRecordTypes that you want to bring in to Salesforce",
    "description": "Choose OpptyRecordTypes that you want to bring in to Salesforce.",
    "required": false,
    "variableType": {
        "type": "ArrayType",
        "itemsType": {
            "type": "StringType",
            "enums": ["Test", "Test2"]
        }
    }
}

Add more values to the ArrayType variable enums:


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

Example

Reduce the possible answers via the excludes:

public override void onConfigurationRetrieval(wavetemplate.WaveTemplateInfo template)
{
    Map<string, wavetemplate.VariableDefinition> variables = template.getVariables();
    wavetemplate.VariableDefinition hasProduct = variables.get('Has_Product');
    Set<string> excludes = new Set<string>();
    excludes.add('Foo');
    excludes.add('Bar');
    hasProduct.setExcludes(excludes);
}

Example

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

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

Example

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

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