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 a page-state pattern (BRApi.State) 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 SQL Table Editor 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 SQL Table Editor

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      ' Only set a default if the parameter has not been set yet.
9      ' (Derive the value however you like — e.g. from the workflow POV or another parameter.)
10      Dim currentEntity As String = BRApi.Dashboards.Parameters.GetLiteralParameterValue(si, False, "EntityParam")
11      If String.IsNullOrEmpty(currentEntity) Then
12          BRApi.Dashboards.Parameters.SetLiteralParameterValue(si, False, "EntityParam", "Houston")
13      End If
14  End If
15End 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          ' XFGetValue takes only the key and returns "" when the key is missing
6          Dim reportType As String = args.NameValuePairs.XFGetValue("ReportType")
7          If String.IsNullOrEmpty(reportType) Then reportType = "Summary"
8          ' Set a parameter to control which report layout to show
9          BRApi.Dashboards.Parameters.SetLiteralParameterValue(si, False, "ActiveReport", reportType)
10
11          Dim result As New XFSelectionChangedTaskResult()
12          result.IsOK = True
13          Return result
14
15      Case "ExportData"
16          Dim format As String = args.NameValuePairs.XFGetValue("Format")
17          If String.IsNullOrEmpty(format) Then format = "CSV"
18          ' Export logic here...
19
20          Dim result As New XFSelectionChangedTaskResult()
21          result.IsOK = True
22          result.ShowMessageBox = True
23          result.Message = "Export completed in " & format & " format."
24          Return result
25
26  End Select
27End If

SqlTableEditorSaveData

Handles SQL Table Editor 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 data adapters configured with CommandType = Method and MethodType = BusinessRule. 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, Param1=[Value1]) (also accepts optional 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")
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")
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

Page State

You can store and retrieve custom key-value state scoped to the current page instance using BRApi.State. Page state persists across interactions within the same page/dashboard session. Use SetPageOrDlgState to save a value and GetPageOrDlgState (which returns an XFUserState) to read it back.
The state is keyed by the page instance ID (args.PageInstanceInfo.PageOrDlgInstanceID), the client module, a related-object type/name pair (use these to namespace your values — e.g. by dashboard name), and two string keys.
1' Store a value in page state
2BRApi.State.SetPageOrDlgState(si, False, args.PageInstanceInfo.PageOrDlgInstanceID, _
3  si.ClientModuleType, "MyDashboard", "", "LastAction", "", "Export", Nothing)
4
5' Retrieve a value from page state
6Dim state As XFUserState = BRApi.State.GetPageOrDlgState(si, False, args.PageInstanceInfo.PageOrDlgInstanceID, _
7  si.ClientModuleType, "MyDashboard", "", "LastAction", "")
8Dim lastAction As String = If(state IsNot Nothing, state.TextValue, String.Empty)
Page state is useful for tracking multi-step processes, remembering the user's last action, or passing state between sequential button clicks without using visible parameters.