Forum Discussion
Marcello
3 years agoContributor
api.Data.SetDataBuffer in increment mode
Hi all,
we have a databuffer with values to be cumulated in a specifi destination intersection.
The issue we have is that api.Data.SetDataBuffer always wirte the last value.
Is there a standard...
- 3 years ago
Hi Giacomo,
we had a call with a Onestream consultant
The final outcome is that we agreed that the best way to handle cumulation is to use the "evergreen" api.Data.GetDataCell and "api.Data.Calculate" (while looping records in the databuffer).
This give us 2 advantages:
- we can instruct the calculation with element names rather than the IDs
- we can debug the calculation line by line
Thanks a lot for the help.
Marcello
Marcello
3 years agoContributor
Hi Giacomo,
thanks for the help but I think you are not 100% right when you say that cell and intersection are equivalent.
From what I understood of Onestream rule they are the same only in the instant in which you open the databuffer (regardless if bufOrig or bufNew ).
But after an api.Data.SetDataBuffer on the resultCell they are different !
You example works fine because you define the ExpressionDestinationInfo at the beginning.
In our example the destination account is dynamically got from an attribute of the account in the databuffer.
So it can happen that 2 different "cells" have to be cumulated on the same destination account.
At the moment, due to lack of official rule documentation and mostly lack of knowledge from our side, I think that dynamic cumulate is almost impossible (unless a "accumulateIfCellAlreadyExists" is available in the "api.Data.SetDataBuffer")
Hope this clears where we got stuck in our developments.
Ciao
Marcello
- JackLacava3 years ago
OneStream Employee
The ExpressionDestinationInfo object can be created at any time, it can even be blank. That doesn't really matter.
Marcello wrote:
But after an api.Data.SetDataBuffer on the resultCell they are different
When you create a buffer object, you are retrieving the current values from the dabase and holding them in memory. All the operations on that object's cells happen in memory.
SetDataBuffer simply pushes the buffer object you have in memory, back to the database. Whatever change you've made to the object's cells, gets saved back into the db.
If you have a buffer object with values, and you want to save them to the database - adding values if necessary - you could retrieve the current status and sum it up with something like :
Dim bufOrig as DataBuffer = api.Data.GetDataBufferUsingFormula(newBuf.CommonDataBufferCellPk.GetMemberScript(api)) api.Data.SetDataBuffer((bufOrig + newBuf), destInfo)There are other approaches. If there is one thing I've learned, is that pretty much everything is possible with OS 😅 so it's just a matter of clarifying what you need.
Related Content
- 2 years ago
- 4 years ago
- 1 month ago