Forum Discussion
RobbSalzmann
10 months agoValued Contributor II
Databuffers are made to be efficient in processing all the cells in one collection(the buffer). Create one databuffer will all your accounts and ICs in it instead of looping over the accounts and ICs one at a time.
This should get you close:
Dim ResultDataBuffer As DataBuffer = New DataBuffer()
Dim sAccounts As List(Of String) = New List(Of String) From {
"1711050",
"2742020",
"1712020",
"2745060",
"1346010",
"2413010",
"1742050",
"2716050",
"1745010",
"2713010",
"3221010",
"3221020",
"3221030",
"4451010",
"4451020",
"4451030",
"1722060",
"2741030",
"4541070",
"4321020",
"4541010",
"4541020",
"3222010",
"4452010",
"4541030",
"4541040",
"4541050",
"4541060",
"5111010",
"5111020"}
Dim accountsFilter As String = String.Join(",", sAccounts.Select(Function(account) $"A#{account}"))
Dim iCsFilter As String = String.Join(",", icMembers.Select(Function(ic) $"I#{ic}"))
Dim DestinationInfo As ExpressionDestinationInfo = api.Data.GetExpressionDestinationInfo($"Filtermembers(O#Forms:UD1#None:UD2#None,[{accountsFilter}],[I#Top_member].Base)")
Dim StartingDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula($"RemoveZeros(O#Forms:UD1#None:UD2#None,[{accountsFilter}],[I#Top_member].Base))")
For Each sourceCell As DataBufferCell In StartingDataBuffer.DataBufferCells.Values
Dim resultCell As New DataBufferCell(sourceCell)
resultcell.SetOrigin(api,"Forms")
resultcell.SetIC(api,Ic.Name)
resultcell.SetAccount(api,Acc)
resultcell.CellAmount = 0
resultCell.CellStatus = DataCellStatus.CreateDataCellStatus(True, False)
'Set target member
ResultDataBuffer.SetCell(si,resultcell)
Next
'Save the Data Buffer using Result Data Buffer and Destination Info
api.Data.SetDataBuffer(ResultDataBuffer,DestinationInfo)
Related Content
- 3 years ago
- 9 months ago
- 8 months ago