Define Richer Widget Interactions with Enhanced Bindings Support

Dynamically set the initial selection in a step based on a binding. Use bindings to generate custom titles for the chart, date, link, list, number, and range widgets. To create more intricate logic, nest bindings.

Control the Initial View of a Dashboard with Bound Selections

You can use a results binding to dynamically set the initial filter selection in a staticflex-, saql-, or soql-type step. For example, to focus the dashboard on the logged-in user’s country, configure the list widget to select the country when the dashboard first opens.

"USA" is automatically selected as the country when you first open the dashboard.

To enable this behavior, first, create a step that retrieves the country of the logged-in user from the Salesforce User object.
"UserData": {
    "groups": [],
    "numbers": [],
    "query": "SELECT Username, Country, FirstName, LastLoginDate 
              FROM User WHERE Name = '!{}'",
    "selectMode": "single",
    "strings": [
    "type": "soql"
Next, bind the initial selection in the list widget’s step to the logged-in user’s country.
"Billing_Country_2": {
    "groups": [],
    "isFacet": true,
    "label": "Billing Country",
    "numbers": [],
    "query": "q = load \"Opp_Icons\";\n
              q = group q by 'Billing_Country';\n
              q = foreach q generate 'Billing_Country' as 'Billing_Country', sum('Amount') as 'sum_Amount';\n
              q = order q by 'sum_Amount' desc;",
    "selectMode": "multi",
    "start": "{{cell(UserData.result, 0, \"Country\").asObject() }}",
    "strings": [],
    "type": "saql",
    "useGlobal": true

Use Nested Bindings to Show Results Based on Dependent Widgets

Nested bindings create deeper dependencies among widgets. For example, the following pie chart shows the number of opportunities for each segment. It filters the results based on the selected grouping in the toggle widget and selected value from that grouping in the horizontal bar chart.

The dashboard shows a toggle with static values: Owner, Country, and Industry. It also contains a bar chart that shows sum of amount, grouped by industry, and a donut chart that shows count of rows, grouped by segment.

To enable the pie chart to filter based on the value of the selected grouping, the step query contains a nested binding.
q = load \"Opportunities1\";\n
q = filter q by {{column(RevenueDynamicGrouping.selection,       
q = group q by 'Segment';\n
q = foreach q generate 'Segment' as 'Segment', count() as 'count';\n
q = order q by 'Segment' asc;\nq = limit q 200;

Convert Binding Results to an Array

When a binding function requires the input to be an array, use the toArray data manipulation binding function. For example, use this function to convert the scalar result of a cell function to an array, which is required by compact-form measures, groups, and order clauses.

The toArray function uses the following syntax:
toArray (input1, input2, . . .)

The input for the toArray function must be scalars (including static values) or one-dimensional arrays. This function converts scalars to a one-dimensional array and one-dimensional arrays to a two-dimensional array. The function returns an error if the input is a series of static one-dimensional arrays, a two-dimensional array, or a mix of scalars and one-dimensional arrays.

To better understand this function, consider the following Opportunities step.
Oppty_Name Owner Region Amount Created_Date
Alpha Danny Americas 1000 2/20/2017
Bravo Danny Americas 500 4/15/2017
Charlie Jeff EMEA 2000 5/1/2017
Now let’s look at some binding examples that use the Opportunities step as a source.
Binding Result
toArray( cell(Opportunities.selection, 0, “Region”) ) [“Americas”]
toArray( “APAC” ) [“APAC”]
toArray( cell(Opportunities.selection, 0, “Region”), “APAC” ) [“Americas”, “APAC”]
toArray( column(Opportunities.selection, [“Oppty_Name”]), column(Opportunities.selection, [“Region] ) [[“Alpha”, “Bravo”, “Charlie”], [“Americas”, “Americas”, “EMEA”]]
toArray( column(Opportunities.selection, [“Oppty_Name”, “Region”]) ) Error. The column binding function returns a two-dimensional array, which is an invalid input.
toArray( [1, 2, 3], [4, 5, 6] ) Error. The input can’t be a series of static one-dimensional arrays.