Forum Discussion
Sergey
OneStream Employee
1 year agoExecuteCustomCalculateBusinessRule ... but in workspaces
Hi,
I came across an update function in the business rules for ExecuteCustomCalculateBusinessRule
Previous function (still in use) : BRApi.Finance.Calculate.ExecuteCustomCalculateBusinessRule(si, brName, functionName, nameValuePairs, timeType)
New function for workspaces : BRApi.Finance.Calculate.ExecuteCustomCalculateBusinessRule(si, workspaceID, brName, functionName, nameValuePairs, timeType)
We can indeed at least in version 8.5 create Finance Custom Calculate Services :
However, these don't use any business rule name, hence my confusion ? How do we execute a custom calculate service which is currently within my workspace assembly services ? Or should it be used in a different way ?
Regards,
When you use services of any type, you never refer to them - you always refer to the Factory that can return them. So "brName" in that context will be:
- Workspace.YourWorkspaceName.WS
- Workspace.YourWorkspaceName.YourMaintUnitName.WSMU
- Workspace.Current.WS (when the factory is in the same workspace as the caller)
- Workspace.Current.Current.WSMU (when the factory is in the same maintenance unit as the caller)
- Workspace.Current.YourMaintUnitName.WSMU (when the factory is in the same Workspace but different Maintenance Unit as the caller)
2 Replies
- JackLacava
OneStream Employee
When you use services of any type, you never refer to them - you always refer to the Factory that can return them. So "brName" in that context will be:
- Workspace.YourWorkspaceName.WS
- Workspace.YourWorkspaceName.YourMaintUnitName.WSMU
- Workspace.Current.WS (when the factory is in the same workspace as the caller)
- Workspace.Current.Current.WSMU (when the factory is in the same maintenance unit as the caller)
- Workspace.Current.YourMaintUnitName.WSMU (when the factory is in the same Workspace but different Maintenance Unit as the caller)
- stubeaverNew Contributor
Hi Sergey,
I hit the same issue recently and wanted to reply with the solution in case it helps others in the future. Apologies if I am reviving an old thread.
The "brName" parameter seems to need to adhere to the same syntax as when calling a custom calculate from within the workspace itself. E.g.
When the service factory is assigned to the maintenance unit, this would be :
Workspace.{WorkspaceName}.{MaintenanceUnitName}.WSMU
I found this out mainly through trial and error. I have included the "Finance Custom Calculate Service" I quickly wrote to figure it out below, in case it helps others troubleshoot.
Public Class WsasFinanceCustomCalculate Implements IWsasFinanceCustomCalculateV800 Public Sub CustomCalculate( ByVal si As SessionInfo, ByVal brGlobals As BRGlobals, ByVal api As FinanceRulesApi, ByVal args As FinanceRulesArgs ) Implements IWsasFinanceCustomCalculateV800.CustomCalculate Try Dim skipCalcForPov As Boolean = ( api.Entity.HasChildren() OrElse api.Cons.IsForeignCurrencyForEntity() ) If skipCalcForPov Then Exit Sub Dim functionName As String = args.CustomCalculateArgs.FunctionName Select Case functionName ' Parent custom calc Case "InitialCustomCalc": api.LogMessage("'InitialCustomCalc' run successfully from service factory.") Dim workspaceName As String = "TestNestedCustomCalc" Dim maintenanceUnitName As String = "TestNestedCustomCalc" Dim workspaceID As Guid = BRApi.Dashboards.Workspaces.GetWorkspaceIDFromName(si, False, workspaceName) ' Trying different brNames Dim brNameOptions As New List(Of String) With brNameOptions .Add("Assembly") .Add("WsAssemblyFactory") .Add("InitialCustomCalc") .Add($"Workspace.{workspaceName}.{maintenanceUnitName}.WSMU") ' This one works .Add($"{workspaceName}") End With For Each brName As String In brNameOptions Dim brParamDict As New Dictionary (Of String, String) From { {"Cube", api.Pov.Cube.Name}, {"Entity", api.Pov.Entity.Name}, {"Consolidation", api.Pov.Cons.Name}, {"Scenario", api.Pov.Scenario.Name}, {"Time", api.Pov.Time.Name}, {"View", api.Pov.View.Name}, {"brName", brName} } BRApi.Finance.Calculate.ExecuteCustomCalculateBusinessRule(si, workspaceId, brName, "BaseEntityCustomCalc", brParamDict, CustomCalculateTimeType.CurrentPeriod) Next brName Case "BaseEntityCustomCalc": Dim brName As String = args.CustomCalculateArgs.NameValuePairs.XFGetValue("brName","") api.LogMessage($"'BaseEntityCustomCalc' run successfully from within 'InitialCustomCalc' using brName '{brName}'.") Case Else: Throw New NotImplementedException($"Function name '{functionName}' not implemented in workspace assembly.") End Select Catch ex As Exception Throw New XFException(si, ex) End Try End SubThanks,
Stuart
Related Content
- 2 years ago