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 Sub
Thanks,
Stuart