Edit variables.json

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" : true
9}

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}

BooleanType variable

1"booleanExample" : {
2    "label" : "Please define the boolean parameter?",
3    "description" : "Some boolean value.",
4    "defaultValue": false,
5    "required" : true,
6    "variableType" : {
7        "type" : "BooleanType",
8    }
9}

SobjectFieldType array variable

1"sobjectFieldArrayExample" : {
2    "label" : "Select the user name fields?",
3    "description" : "The user fields to use.",
4    "defaultValue" : [
5       {"sobjectName" : "User", "fieldName" : "FirstName"},
6       {"sobjectName" : "User", "fieldName" : "LastName"},
7    ],
8    "required" : true,
9    "variableType" : {
10       "type":"array"
11    }
12    "itemsType" : {
13        "type" : "SobjectFieldType",
14        "dataType" : "xsd:string"
15     }
16    }
17}

To use this variable, call it with the following:

1${Variables.sobjectFieldArrayExample[0].sobjectName}
2${Variables.sobjectFieldArrayExample[0].fieldName}
3${Variables.sobjectFieldArrayExample[0]}

See additional detail and examples in the sections that follow.

  • Simple Variable Types for variables.json

    We call the following variable types “simple” because they’re standard, predefined datatypes.

  • Complex variables.json Variable Types

    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.

  • Array Variable Type for variables.json

    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.

  • excludes and excludeSelected Attributes in Variables

    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.

  • Use Case and Syntax for Variables with Related Values

    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.

See Also