Interaction Functions

Dashboard designer dashboards support a variety of interaction functions that get data from a source query, manipulate it, and serialize it to make it consumable by the target query.

If the input data has empty results, the function returns a null value. If the specified location of the data doesn’t exist, an error occurs. For example, the interaction is defined to get data from row 3, but row 3 doesn’t exist. An error also occurs if the shape of the input data doesn’t meet the requirement for the function.

Interaction functions operate on input data with one of these shapes.

  • Scalar value, like 0, "this is scalar", or null.

  • One-dimensional array, like ([1, 2, 3]) or (["one","two","three"])

  • Two-dimensional array (an array of arrays), like ([ [1, 2], [3, 4] ])

The required shape of the input data varies with each function. After processing the data, the functions can change the shape of the data.

Each interaction consists of nested functions. Each interaction must have one data selection function and one data serialization function. Optionally, interactions can have multiple data manipulation functions. This example illustrates how nested functions in an interaction work together to produce the expected result for a target query in which they’re defined. The example is based on this interaction.

The mySourceStep query has this input data.

Regional Arearegion

Technically, the data for this query is stored as a two-dimensional array, where each row is stored as a map of key-value pairs.

At runtime, CRM Analytics evaluates the interaction functions, starting with the innermost function. Using that logic, CRM Analytics evaluates the example’s interaction functions in this order.

mySourceStep.selectionCRM Analytics returns each row of selected data as a map of key-value pairs. If a single selection is made, only one row returns. If multiple selections are made, multiple rows return.
cell(mySourceStep.selection, 0, \"grouping\")The cell function returns a scalar value from the "grouping" column of the first row (indicated by the 0 index) returned by mySourceStep.selection. Based on the selection, the return value can be "region", "country", or "state". If no selection is made, the function returns null.
coalesce(cell(mySourceStep.selection, 0, \"grouping\"), \"state\")The coalesce function returns the value of the cell function if a selection was made. If no selection was made, the coalesce function returns the specified default value "state".
coalesce(cell(mySourceStep.selection, 0, \"grouping\"), \"state\").asString()The .asString function returns the result of the coalesce function as a SAQL string.

Use the coalesce function to provide a default value so that an error doesn’t occur when a null value is encountered.