Dashboards

Dashboard Business Rules

Dashboard Business Rules power the server-side logic behind interactive dashboards. There are three types — each serving a different purpose in the dashboard lifecycle. This guide covers all three with complete code examples, the LoadDashboard lifecycle, and the PageState API for storing custom state.

Dashboard BR Types

diagramDashboard Business Rule Types

Loading diagram...

Dashboard Extender

The Dashboard Extender handles dashboard lifecycle events and user interactions. It receives a DashboardExtenderArgs object with properties that describe what triggered the rule and provide context.

DashboardExtenderArgs Properties

PropertyTypeDescription
FunctionTypeDashboardExtenderFunctionTypeWhich event triggered the rule (see enum below)
FunctionNameStringThe function name from curly brace syntax {BR}{FunctionName}{NVPs}
NameValuePairsDictionary(Of String, String)Key-value pairs from curly brace syntax
PrimaryDashboardDashboardThe top-level dashboard object
EmbeddedDashboardDashboardThe embedded dashboard (if the component is in one)
ComponentInfoDashboardCompInfoInformation about the component that triggered the event
PageInstanceInfoPageInstanceInfoInformation about the current page instance
LoadDashboardTaskInfoXFLoadDashboardTaskInfoContext for LoadDashboard events (Reason, Action)
SelectionChangedTaskInfoXFSelectionChangedTaskInfoContext for selection change events
SqlTableEditorSaveDataTaskInfoXFSqlTableEditorSaveDataTaskInfoContext for DynamicGrid save events

DashboardExtenderFunctionType Enum

ValueNameTriggered By
0LoadDashboardDashboard is loading (opening or refreshing)
1ComponentSelectionChangedUser clicked a Button or changed a selection in a ComboBox/ListBox
2SqlTableEditorSaveDataUser saved changes in a DynamicGrid

LoadDashboard

The LoadDashboard function type fires when a dashboard opens or refreshes. It provides two key properties on args.LoadDashboardTaskInfo that tell you why and when the rule is firing.
diagramLoadDashboard Lifecycle

Loading diagram...

LoadDashboardTaskInfo Properties

PropertyValuesDescription
ReasonInitialize, ComponentSelectionChangedInitialize on first load. ComponentSelectionChanged when a component refresh triggers a reload.
ActionBeforeFirstGetParameters, BeforeSubsequentGetParameters, BeforeGetDashboardDisplayInfoWhich phase of the load lifecycle the rule is currently in.

LoadDashboard Example: Set Default Parameter Values

1If args.FunctionType = DashboardExtenderFunctionType.LoadDashboard Then
2  Dim reason As LoadDashboardReasonType = args.LoadDashboardTaskInfo.Reason
3  Dim action As LoadDashboardActionType = args.LoadDashboardTaskInfo.Action
4
5  ' Set defaults only on first load, before parameters are prompted
6  If reason = LoadDashboardReasonType.Initialize AndAlso _
7     action = LoadDashboardActionType.BeforeFirstGetParameters Then
8      ' Set default entity from the user's session POV
9      Dim defaultEntity As String = BRApi.Finance.Members.GetMemberInfo(si, DimType.Entity.Id, si.Entity, True).Member.Name
10      BRApi.Dashboards.Parameters.SetLiteralParameterValue(si, False, "EntityParam", defaultEntity)
11  End If
12End If

ComponentSelectionChanged

Fires when a user clicks a Button or changes a selection in a ComboBox/ListBox that has a server task configured. The curly brace syntax on the component maps directly to args.FunctionName and args.NameValuePairs.
diagramCurly Brace Argument Mapping

Loading diagram...

ComponentSelectionChanged Example

1If args.FunctionType = DashboardExtenderFunctionType.ComponentSelectionChanged Then
2  Select Case args.FunctionName
3
4      Case "RunReport"
5          Dim reportType As String = args.NameValuePairs.XFGetValue("ReportType", "Summary")
6          ' Set a parameter to control which report layout to show
7          BRApi.Dashboards.Parameters.SetLiteralParameterValue(si, False, "ActiveReport", reportType)
8
9          Dim result As New XFSelectionChangedTaskResult()
10          result.IsOK = True
11          Return result
12
13      Case "ExportData"
14          Dim format As String = args.NameValuePairs.XFGetValue("Format", "CSV")
15          ' Export logic here...
16
17          Dim result As New XFSelectionChangedTaskResult()
18          result.IsOK = True
19          result.ShowMessageBox = True
20          result.Message = "Export completed in " & format & " format."
21          Return result
22
23  End Select
24End If

SqlTableEditorSaveData

Handles DynamicGrid save operations. See DynamicGrid and SQL Table Editor for the full save handler pattern with XFSqlTableEditorSaveDataTaskInfo and XFSqlTableEditorSaveDataTaskResult.

Dashboard DataSet

Dashboard DataSet BRs provide data to components via Custom data adapters. The BR implements two function types: GetDataSetNames (returns a list of available dataset names) and GetDataSet (returns a DataTable for a specific dataset).
diagramDataSet Request Flow

Loading diagram...

DashboardDataSetArgs Properties

PropertyTypeDescription
FunctionTypeDashboardDataSetFunctionTypeGetDataSetNames or GetDataSet
DataSetNameStringThe requested dataset name (populated for GetDataSet)
PageInstanceInfoPageInstanceInfoCurrent page instance info
NameValuePairsDictionary(Of String, String)Additional context passed from the adapter configuration
CustomSubstVarsDictionary(Of String, String)Custom substitution variables

Dashboard DataSet Example

1Select Case args.FunctionType
2
3  Case DashboardDataSetFunctionType.GetDataSetNames
4      Dim names As New List(Of String)()
5      names.Add("RevenueByEntity")
6      names.Add("ExpenseSummary")
7      Return names
8
9  Case DashboardDataSetFunctionType.GetDataSet
10      If args.DataSetName.XFEqualsIgnoreCase("RevenueByEntity") Then
11          ' Build a DataTable with revenue data
12          Dim dt As New DataTable()
13          dt.Columns.Add("Entity", GetType(String))
14          dt.Columns.Add("Revenue", GetType(Decimal))
15          dt.Columns.Add("Variance", GetType(Decimal))
16
17          ' Query cube data and populate the table
18          Using dbConnApp As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
19              Dim sql As String = "SELECT Entity, SUM(Amount) AS Revenue, 0 AS Variance FROM dbo.FinancialData WHERE Account = 'Revenue' GROUP BY Entity"
20              Dim sourceTable As DataTable = BRApi.Database.ExecuteSql(dbConnApp, sql, False)
21              For Each sourceRow As DataRow In sourceTable.Rows
22                  Dim newRow As DataRow = dt.NewRow()
23                  newRow("Entity") = sourceRow("Entity")
24                  newRow("Revenue") = sourceRow("Revenue")
25                  newRow("Variance") = 0D
26                  dt.Rows.Add(newRow)
27              Next
28          End Using
29
30          Return dt
31
32      ElseIf args.DataSetName.XFEqualsIgnoreCase("ExpenseSummary") Then
33          ' Build expense summary DataTable...
34          Dim dt As New DataTable()
35          dt.Columns.Add("Category", GetType(String))
36          dt.Columns.Add("Amount", GetType(Decimal))
37          Return dt
38      End If
39
40End Select

Dashboard String Function (XFBR / BRString)

Dashboard String Function BRs return string values used in dashboard component parameters and properties. They are called using BRString(...) or XFBR(...) syntax wherever a parameter or property value is needed.

DashboardStringFunctionArgs Properties

PropertyTypeDescription
FunctionNameStringThe function name from the BRString(RuleName, FunctionName, ...) call
NameValuePairsDictionary(Of String, String)Key-value pairs from the BRString(RuleName, FunctionName, Key=Value) call
PageInstanceInfoPageInstanceInfoCurrent page instance info
SubstVarSourceInfoSubstVarSourceInfoContext about the substitution variable source
CustomSubstVarsDictionary(Of String, String)Custom substitution variables from the dashboard

Calling Syntax

  • BRString: BRString(RuleName, FunctionName, Param1=Value1, Param2=Value2)
  • XFBR: XFBR(RuleName, FunctionName) (no name-value pairs)
  • Assembly XFBR: XFBR(Workspace.WorkspaceName.AssemblyName.FileName, FunctionName)
diagramXFBR Resolution Flow

Loading diagram...

String Function Example

1Select Case args.FunctionName
2
3  Case "GetEntityDescription"
4      ' Return the description of an entity member
5      Dim entityName As String = args.NameValuePairs.XFGetValue("Entity", String.Empty)
6      If Not String.IsNullOrEmpty(entityName) Then
7          Dim memberInfo As MemberInfo = BRApi.Finance.Members.GetMemberInfo(si, DimType.Entity.Id, entityName, True)
8          If memberInfo IsNot Nothing Then
9              Return memberInfo.Member.Description
10          End If
11      End If
12      Return entityName
13
14  Case "IsUserAdmin"
15      ' Return True/False based on security role
16      Dim isAdmin As Boolean = BRApi.Security.Authorization.IsUserInGroup(si, si.UserName, "Administrators", False)
17      Return isAdmin.ToString()
18
19  Case "GetVisibility"
20      ' Control component visibility based on scenario
21      Dim scenario As String = args.NameValuePairs.XFGetValue("Scenario", String.Empty)
22      If scenario.XFEqualsIgnoreCase("Actual") Then
23          Return "False"  ' Hide for Actual scenario
24      End If
25      Return "True"
26
27End Select
28
29Return String.Empty
Usage in dashboard component properties:
  • BRString(MyStringBR, GetEntityDescription, Entity=[|!SelectedEntity!|]) — Returns entity description
  • BRString(MyStringBR, IsUserAdmin) — Returns True/False for conditional logic
  • BRString(MyStringBR, GetVisibility, Scenario=[|!ScenarioParam!|]) — Controls IsVisible property

PageState

The PageState API lets you store and retrieve custom key-value pairs scoped to the current page instance. Values persist across interactions within the same dashboard session but are cleared when the user navigates away.
1' Store a value in PageState
2BRApi.Dashboards.Process.PageState.SetItem(si, args.PageInstanceInfo, "LastAction", "Export")
3
4' Retrieve a value from PageState
5Dim lastAction As String = BRApi.Dashboards.Process.PageState.GetItem(si, args.PageInstanceInfo, "LastAction", String.Empty)
PageState is useful for tracking multi-step processes, remembering the user's last action, or passing state between sequential button clicks without using visible parameters.