Forum Discussion
Is the Entity, Time, Scenario and Cons being fed into a data management step which is calling this rule? You can only clear the data within the data unit defined in the DM step. Within your databuffer member filter, you don't need to define the entity, scenario, time, and cons because the rule will assume those members from the POV in the data management step.
For example, below the Entity MF has a .base expansion. The custom calculate will run for every base entity and you can only clear the entity that is currently running. To know which enetity is running, you can use api.pov.Entity.Name. To pass a specific entity, you can put E#|!Entity!| in the entity filter, and then below in the parameters put Entity = |!Entity!|. Within the component calling the DM step, define entity with the real param, so Entity = |!param_Entity!|.
Below is a more performative way to clear databuffer cells. Instead of setting them all individually, you can collect all the cells you want to set to zero, and then set them all at once. This limits the amount of database interactions.
Private Sub ClearAll(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As FinanceRulesApi, ByVal args As FinanceRulesArgs)
Dim destination As ExpressionDestinationInfo = api.Data.GetExpressionDestinationInfo("V#YTD")
'retrieve the data buffer to clear, loop through the cells, and set the cell amounts to zero and the cell status to NoData
Dim sourceBufferr As DataBuffer = api.Data.GetDataBufferUsingFormula("RemoveZeros(FilterMembers(V#YTD))",,False,,,,)
For Each sourceCell As DataBufferCell In sourceBufferr.DataBufferCells.Values
sourceCell.CellAmount = 0
sourceCell.CellStatus = DataCellStatus.CreateDataCellStatus(True, False)
resultBufferToClear.SetCell(si, resultCell)
Next
'clear out the cells
api.Data.SetDataBuffer(sourceBufferr, destination,,,,,,,,,,,,,False)
End Sub
Related Content
- 10 months ago
- 17 days ago