07-12-2023 05:25 PM
Hello OneStream Community,
I am using the SaveDataEventHandler to validate a cell amount being saved. Depending on certain conditions I update the amount in the “args.NewDataCell.cellAmount” and set “args.Cancel = False”.
Instead of the modified amount in “args.NewDataCell.cellAmount” the original amount entered gets saved.
In the snippet of the code below, a sample error log output when a user inputs 4.3466 in a form would be:
Amount Before = 4.3466
Amount After = 4.35
But the saved amount in the form will be 4.3466.
----Snippet Start-----
BRapi.ErrorLog.LogMessage(si,"Amount Before = " & args.NewDataCell.CellAmount)
args.NewDataCell.CellAmount = Math.Round(args.NewDataCell.CellAmount, 2, MidpointRounding.AwayFromZero)
BRapi.ErrorLog.LogMessage(si,"Amount After = " & args.NewDataCell.CellAmount)
args.Cancel = False
----Snippet End-----
Please advise.
07-13-2023 02:45 AM
Hi, apologies, but this is not the answer you are looking for. I recommend not using any rules to round data in the system. Rounding data should be done in and for reporting purposes only. I, personally, have not come across a use case where I thought rounding in rules is ok (though such a use case may exist, of course).
In addition to that, save data event handler have to be used with great care as they may have an adverse impact on performance.
07-14-2023 04:04 PM
Henning,
Thank you for your response. I appreciate your comment. This is a unique request from the client that we have to implement. Also, we trap validation errors and show popup messages from the save event handler on other applications without a considerable performance hit.
If you know of a way how we can save the altered data, it would be much appreciated.
07-13-2023 09:23 AM
Hi, I agree with Henning this will have impact on performance as every time any user submits data this event handler will execute the code.
If you want to round specific intersections, I will suggest using a finance rule.
Thanks, Omkareshwar
Archetype Consulting