DavidW
2 years agoNew Contributor II
Calling finance rule from XFBR rule
This post is to illustrate how to call a public function of a Finance Rule from within XFBR rule.
The Finance Rule has a function called EntityText8 splitter, and I need to call it from within a XFBR rule. To make it work, first need to make the Finance Rule "True" - Contains Global Functions for Formulas (in Rule Properties) and refer to the specific rule assembly in XFBR rule properties (screenshot2).
The XFBR rule reads:
'--------------------------------------------------------------------------------------------------------------------------------
'Returns the Entity in Text8 or emtpy
'--------------------------------------------------------------------------------------------------------------------------------
'BRString(SeedingXFBRStrings, Text8Entity, curEntity=|CVEntity|, curScenario=|CVScenario|)
'XFBR(SeedingXFBRStrings, Text8Entity, curEntity=|CVEntity|, curScenario=|CVScenario|)
If args.FunctionName.XFEqualsIgnoreCase("Text8Entity") Then
Dim curEntity As String = args.NameValuePairs.XFGetValue("curEntity")
Dim curScenario As String = args.NameValuePairs.XFGetValue("curScenario")
Dim scenarioId As Integer = BRApi.Finance.Members.GetMember(si, DimType.Scenario.Id, curScenario).MemberId
Dim curScenarioType As String = BRApi.Finance.Scenario.GetScenarioType(si, scenarioId).Id
Dim entityId As Integer = brapi.Finance.Members.GetMemberId(si, DimType.Entity.Id, curEntity)
Dim entityText8 As String = BRApi.Finance.Entity.Text(si, entityId, 8, curScenarioType, si.WorkflowClusterPk.TimeKey)
If entityText8.Length > 0 Then
'Define reference to business rule
Dim text8Splitter As New OneStream.BusinessRule.Finance.FcstSeeding.MainClass
If Not text8Splitter Is Nothing Then
Dim srcEntity As String
With text8Splitter.entityText8Splitter(entityText8)
srcEntity = .srcEntity
End With
Return srcEntity
Else
Return entityText8
End If
Else
Return ""
End If
End If