Formula/Expression field: Balance

Posted by Rollbase User on 14-Aug-2013 13:29

I need some inspiration for a formula/expression field to calculate a balance column. The result in the grid view would look something like this: ID | Amount | Balance 1 | 1000 | 1000 2 | -300 | 700 3 | 400 | 1100 4 | 500 | 1600 5 | -50 | 1500 So I need a formula to add the amount to the previous balance value. ID1.Amount + ID0.Balance = 1000 ID2.Amount + ID1.Balance = 700 and so on. Again, think of a basic Accounting Ledger. Any ideas? Is it even possible to reference a previous row value in a grid?

All Replies

Posted by Admin on 15-Aug-2013 11:01

Hello Surferking,



it's possible to iterate through records to access/manipulate their fields. Please refer to our official documentaion, Rollbase in Action on Page 143, "Chapter 6: Server-Side Code: Templates, Formulas and the Rollbase Query API". This chapter contains a great deal of information in retrieving and manipulating application data.



Here are a couple of forum topics which use the Rollbase API:

https://getsatisfaction.com/rollbase/topics/cancelling_an_appointment-ohj7o

https://getsatisfaction.com/rollbase/topics/how_to_create_a_log_for_the_field_not_using_audit_trail

https://getsatisfaction.com/rollbase/topics/filter_related_records



As you can see, it's possible to retrieve and assign values of record fields using the rbv_api.setFieldValue and rbv_api.getFieldValue APIs.



The third link provided above utilizes the Rollbase API rbv_api.selectQuery, which returns a 2D array based on a given SQL SELECT query. It coul

This thread is closed