OSAdmin
Valued Contributor

DashboardDataSet Rules are used to create programmatic query results. This rule type enables the rule writer to combine multiple types of data into a single result set using the full syntax capability of VB.Net.

 

'------------------------------------------------------------------------------------------------------------
    'Reference Code:   SampleDashboardDataSet 
    '
    'Description:   Creates an AOD.Net DataTable that selectively returns help desk tickets based on user
    '      level, ticket status and ticket priority.
 
    'Usage:     Used as custom method query in a Dashboard Data Adapter with the following parameter structure.
    'Parameter ProtoType: {SampleDashboardDataSet}{DataSetFunctionName}{Param1="Paramater Value to be used in Data Set"}
    'Parameter Example:  {SampleDashboardDataSet}{DataSetFunctionName}{Param1="Value1"}
    '
    'Created By:   OneStream Software
    'Date Created:   06-1-2016
    '------------------------------------------------------------------------------------------------------------  
    Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardDataSetArgs) As Object
        Try
            Select Case args.FunctionType
     
                Case Is = DashboardDataSetFunctionType.GetDataSet
                    If (args.DataSetName.XFEqualsIgnoreCase("TicketAnalysis")) Then
                        Using dbConnApp As DBConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si) 
                            'Get passed in parameters
                            Dim paramValue1 As String = args.NameValuePairs.XFGetValue("Param1", Guid.Empty.ToString)
       
                            'Execute a SQL query that filters tickets by user name for Non-Administrators
                            Dim sql As New Text.StringBuilder
                            Dim whereClause As New Text.StringBuilder 
                            sql.AppendLine("Select * From TableName ")           '<- Update SQL Query
        
                            'Check Param1
                            If Not paramValue1.Equals("XXXX",StringComparison.InvariantCultureIgnoreCase) Then  '<- Update tested value
                                'Update where clause based on parameter value
                                whereClause.AppendLine("And Field1 = 'XXXX' ")         '<- Update SQL
                            Else
                                'Update where clause based on parameter value
                                whereClause.AppendLine("And TicketStatus = 'XXXX' ")       '<- Update SQL
                            End If

                            sql.AppendLine(whereClause.ToString)
        
                            'Return results of DataSet SQL
                            Return BRAPi.Database.ExecuteSql(dbConnApp, sql.ToString, True)         
                        End Using 
                    End If
                End Select

                Return Nothing
    
            Catch ex As Exception
                Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
            End Try
        End Function
    End Class
Version history
Last update:
‎04-07-2022 01:59 PM
Updated by:
Contributors