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.
For example, the first question on a wizard page asks the user to select an object (sObjectType variable). The next questions can ask the user to select fields (sObjectFields variable) from that object. The wizard populates the questions about fields with sObjectFields from the sObject selected in the first question. The following image shows an sObject picker first, followed by an sObjectField picker.
You can take the same approach with datasets and dataset dates, measures, and dimensions. The first question references a dataset (datasetType variable). Subsequent questions reference dates (datasetDateType), dimensions (datasetDimensionType), and measures (datasetMeasureType) from the dataset selected in the first question.
Following is template JSON used to render the UI shown in the image, using sObject and sObjectFields variables. In the variables section, notice CSATField variable’s type info: the defaultValue contains a reference to the variable’s value CSATObj and the syntax is {{Variables.CSATObj.sobjectName}}. The intention here’s to replace {{Variables.CSATObj.sobjectName}} with the value that the user picked for the variable CSATObj.
The ui.json file for the template, shown at the top of the example, orders the wizard questions defined in variables.json.
1{2 "ui" : {3 "pages" : [4 {5 "title ": "Page1",6 "variables" : [7 {8 "name" : "CSATObj"9 },10 {11 "name" : "CSATField"12 }13 ]14 }15 ]16 },17 "variables" : {18 "CSATObj" : {19 "description" : "Service Analytics defaults to the Case object. If you use a different object to track CSAT, select it from the list below",20 "label" : "1. What object do you use to track customer satisfaction?",21 "required" : true,22 "variableType" : {23 "type" : "SObjectType"24 },25 "defaultValue" : {26 "sobjectName" : "Case"27 }28 },29 "CSATField" : {30 "description" : "Service Analytics uses your choice to provide a single numerical score to indicate customer satisfaction rating.",31 "label" : "2. Which field on the object you just selected do you use to track CSAT?",32 "defaultValue" : {33 "datasetId" : "{{Variables.CSATObj.sobjectName}}",34 "fieldName" : ""35 },36 "required" : true,37 "excludeSelected" : true,38 "variableType" : {39 "type" : "SobjectFieldType",40 "datatype" : "xsd:double"41 }42 }43 }44}