The variables.json file describes all the variables used in the template-info.json, ui.json, and the different rules.json files.
variables.json includes text for wizard questions, descriptions, and specifications for the answers. Variables also define conditional questions. For example, if you want some questions to appear in the wizard only if an org contains certain data. Or you want to add more specific questions based on the answers to more general wizard questions.
Variables enable the customization of apps; without them, everything is hard-coded. Variables allow the framework to replace tokenized data with customer-specific data.
Variables Syntax
Variables are declared in the following format:
1{2 "<variableName>" : <variableDefinition>3}
Each variable has a unique name. Here are the parts of a variable definition.
label
(Required) Text for the label in the wizard, formatted as a question the user selection answers.
description
(Optional) Text for the description in the wizard, formatted to help the user select the correct response.
defaultValue
(Optional) Default value for the answer to the wizard question.
required
(Optional) Indicates whether an answer to the wizard question is required (true) or not (false). The default is false.
variableType
(Optional) The type of the variable. The list of valid variable types is here. Defaults to StringType if not specified.
excludes
(Optional) Defines values to exclude from selections in response to the wizard question. The values are a list of comma-separated field names or regex tokens to not show in a picker.
excludeSelected
(Optional) Excludes previously selected values from selections in response to subsequent wizard questions. The default is false. If there are two or more pickers with the same source and variable type and this field is true for both, the selected option is excluded from the list of options in the other picker.
Examples
Generic variable
1"<Name of a variable>" : { 2 "label" : "<Question to display>",3 "description" : "<Text to help user select/provide the right value>", 4 "variableType" : { "type" : "SobjectType" },5 "defaultValue" : { "sobjectName": "User" }, 6 "required" : true,7 "excludes" : [ "AboutMe", "Division"],8 "excludeSelected" : true9}
NumberType variable with enumerated values
1"numberExampleByTens" : {2 "label" : "What's the maximum number to use for the offset?",3 "description" : "Choose a value between 10 and 100",4 "defaultValue" : 80,5 "required" : true,6 "variableType" : {7 "type" : "NumberType",8 "min" : 0,9 "max" : 100,10 "enums" : [10,20,30,40,50,60,70,80,90,100]11 }12}
Complex variable types are unique to Salesforce, for example, sobject, sobjectField. Use them to query the org for access to data from Salesforce objects. Scroll to the right to view example values. Examples for each type appear below the chart.
Use an ArrayType variable to create a wizard question that accepts multiple selections. The user can make multiple choices from a list of values. Define a minimum and maximum for the number of items that can be selected.
In variables, use the excludes attribute in variables to define values to exclude from selections in response to wizard questions. Use the excludeSelected attribute to exclude values that have already been selected in previous wizard questions.
Construct variables that reference related values, for example an object and fields from the object, and a dataset and dates, dimensions, and measures from the dataset.