Forum Discussion
Gidon_Albert
3 years agoContributor II
Keep in mind that a parameter must reference a Dashboard Data Set BR. Of course, the Dashboard Data Set BR can reference a Finance BR, but you will have to convert the member list to a data table before returning it to the parameter. Here's an example of a Dashboard Data Set BR that is calling a function in a Finance BR. Note that the Finance BR returns a List (of Member) that is then converted into a data table at the bottom section of the rule (starting at the 'Create the data table to return to the parameter section')
Private Function Get_Non_Zero_Members(ByVal si As SessionInfo, ByVal api As Object, ByVal args As DashboardDataSetArgs) As DataTable
Try
'Example of how to call this from a parameter:
'{ADU_HelperQueries}{Get_Non_Zero_Members}{Member_Filter=E#Tot_USG.Base, Value_Filter=A#USG_PPE, Sort_By=Name, Sort_Order= Ascending}
'Get Workflow Scenario ID
Dim wfScenarioName As String = ScenarioDimHelper.GetNameFromID(si, si.WorkflowClusterPk.ScenarioKey)
Dim wfScenarioId As String = ScenarioDimHelper.GetIdFromName(si, wfScenarioName).ToString
'Get Time from current Workflow
Dim myWorkflowUnitPk As WorkflowUnitPk = BRApi.Workflow.General.GetWorkflowUnitPk(si)
Dim wfTime As String = BRApi.Finance.Time.GetNameFromId(si, myWorkflowUnitPk.TimeKey)
Dim memberFilter As String = args.NameValuePairs.XFGetValue("Member Filter", String.Empty)
Dim valueFilter As String = "CB#NVL_Consol:C#Local:S#" & wfScenarioName & ":T#" & wfTime & ":V#YTD:F#End_Bal:O#BeforeAdj:I#Top:U1#Tot_USG_Data_Types:U2#Tot_Departments:U3#Tot_Product_Groups:U4#None:U5#None:U6#None:U7#None:U8#None:"
valueFilter = valueFilter & args.NameValuePairs.XFGetValue("Value Filter", String.Empty)
Dim sortBy As String = args.NameValuePairs.XFGetValue("Sort By", String.Empty)
Dim sortOrder As String = args.NameValuePairs.XFGetValue("Sort Order", String.Empty)
Dim rank As String = args.NameValuePairs.XFGetValue("Rank", "None")
Dim memListHeader As New MemberListHeader(args.DataSetName)
'********* debug info *********
If debugSwitch = True Then brapi.ErrorLog.LogMessage(si,"ADU_HelperQueries.Get_Non_Zero_Members" & vbCrLf &
"args.DataSetName: " & args.DataSetName & vbCrLf &
"memberFilter: " & memberFilter & vbCrLf &
"valueFilter: " & valueFilter & vbCrLf &
"sortBy: " & sortBy & vbCrLf &
"sortOrder: " & sortOrder & vbCrLf &
"rank: " & rank)
'******************************
'Create lists for ranking
' Dim membersAndValues As New List(Of MemberAndCellValue)
Dim memberList As New List(Of Member)
Dim memberInfoList As New List(Of MemberInfo)
' Dim cubeName As String = New MemberScriptBuilder(valueFilter).Cube
'Define the Advanced Developer Utility rule
Dim fsArgs As New FinanceRulesArgs
Dim ADU As New OneStream.BusinessRule.Finance.ADU_Advanced_Developer_Utility.MainClass
'Get the list of members from the Finance BR
Dim topNMems As List(Of Member) = ADU.Get_Non_Zero_Members(si, api, fsArgs, memberFilter, valueFilter, SortBy, sortOrder, Rank)
'Dim topNMemList As New MemberList(memListHeader, topNMems) '<<< This works in the Finance BR, but must be converted into a data table in the Dashboard Data Set BR
'Create the data table to return to the parameter
Dim dt As New DataTable("topNMemsTbl")
Dim nameCol = New DataColumn
nameCol.ColumnName = "Name"
nameCol.DataType = GetType(String)
nameCol.DefaultValue = ""
nameCol.AllowDBNull = False
dt.Columns.Add(nameCol)
Dim descriptionCol = New DataColumn
descriptionCol.ColumnName = "Description"
descriptionCol.DataType = GetType(String)
descriptionCol.DefaultValue = ""
descriptionCol.AllowDBNull = False
dt.Columns.Add(descriptionCol)
'loop through the items in topNMems and add them to the dt table
For Each nMem In topNMems
'Create a new row and append it to the table
Dim row As DataRow = dt.NewRow()
row("Name") = nMem.Name
row("Description") = nMem.Description
dt.Rows.Add(row)
Next nMem
Return dt
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
Related Content
- 4 months ago
- 10 months ago