Forum Discussion

lrossi1's avatar
lrossi1
New Contributor
4 days ago

Need help passing business rule into scenario member filter of Cube View.

I have a cube view with 12 columns (one for each  month). It is used in a quarterly activity, and the columns need to reflect the appropriate forecast scenario depending on which workflow was opened. (e.g. in June 2026, the cube view would have the 6+6 Forecast for Jul thru Dec). I've created the below BR to determine each forecast should be used, but now I'm unsure what I need to enter into the cube view scenario member filter for the columns to use this BR:

Public Function OCF_FcstScenarioSelect(ByVal si As SessionInfo, ByVal api As Object, ByVal args As FinanceRulesArgs) As Object
    Try
        ' Workflow POV time (from workflow context)
        Dim wfTime As String = api.Workflow.Time.Name
        Dim wfPos As Integer = wfTime.IndexOf("M"c)
        Dim wfYear As Integer = CInt(wfTime.Substring(0, wfPos))
        Dim wfMonth As Integer = CInt(wfTime.Substring(wfPos + 1))

        ' Column POV time (from cube view)
        Dim colTime As String = api.Pov.Time.Name
        Dim colPos As Integer = colTime.IndexOf("M"c)
        Dim colYear As Integer = CInt(colTime.Substring(0, colPos))
        Dim colMonth As Integer = CInt(colTime.Substring(colPos + 1))

        Dim scen As String

        ' Determine scenario per column
        If (colYear < wfYear) OrElse (colYear = wfYear AndAlso colMonth <= wfMonth) Then
            scen = "ActBud"
        Else
            Select Case wfMonth
                Case 3 : scen = "Forecast_3_9"
                Case 6 : scen = "Forecast_6_6"
                Case 9 : scen = "Forecast_9_3"
                Case Else : scen = "ActBud"
            End Select
        End If

        Return scen

    Catch ex As Exception
        Throw ErrorHandler.LogWrite(si, New Exception("Error in OCF_FcstScenarioSelect: " & ex.Message))
    End Try
End Function

I would appreciate any help, as I'm new to using BR's for this purpose, and I have been unsuccessful in finding a solution to my specific issue via search engines.

Thanks in advance!

2 Replies

  • sameburn's avatar
    sameburn
    Contributor III

    Hi lrossi1​ 

    One of the issues you might be having could be to do with the api object you are passing into your function 

    E.g it sounds and looks like you are using a Finance BR... but you are not passing in the FinanceRulesApi into your function. 

    If this is the case, you should use api as FinanceRulesApi... not api as Object. This will enable you to use the finance rules api in your logic

    Have a look at the boilerplate code when you create a new Finance BR for context

    I'd also recommend adding logging lines to demystify what your code is doing at runtime 

    Hope this helps 

    Sam

  • lrossi1's avatar
    lrossi1
    New Contributor

    It seems that my BR is probably the issue, but I'm not sure how to fix it