Retrieving the Previous Balance and Calculating the Current Balance

Article Number:040738

By using the Actions feature, you can retrieve the previous balance and then calculate the current total balance in an app.
Actions setting

This topic explains how to calculate the current total balance by adding deposits and subtracting withdrawals based on the balance as of yesterday.

Configuring Fields

Add the following fields to the Form in the app you are creating. Then, set the app name to "Cash Deposits and Withdrawals app".

Example of field settings
Field Name Field code Field Type
Date Date Date
Balance as of Yesterday Balance_as_of_Yesterday Number
Deposit Deposit Number
Withdrawal Withdrawal Number
Total Balance Total_Balance Calculated
- Formula: Balance_as_of_Yesterday + Deposit - Withdrawal

After placing the above fields, save the Form.

Configuring the Actions

Next step is to configure the Actions feature.

  1. On the "App Settings" screen, select the App Settings tab, and then click Actions under Advanced Settings.

  2. Click Add on the upper right of the screen.

  3. Configure the settings for the action and click Save.
    The following shows an example of the settings.

    Example of Action Settings
    Action Name Add record and get the balance
    Target Cash Deposits and Withdrawals app (This app)
    Field Mappings Total Balance > Balance as of Yesterday
    Available To: Everyone

    Screenshot of example action settings

  4. Go back to App Settings and click Update App.

  5. On the confirmation dialog, click Update App.

Adding a Record and Retrieving the Previous Balance to Calculate the Total Balance

  1. Open the "Cash Deposits and Withdrawals" app, then click the Add Record icon at the upper right of the screen.
  2. Enter a number into each field and save the record.
    "Total Balance" will be calculated automatically according to the specified formula. Screen showing the "Total Balance" is calculated automatically
  3. On the Record Details screen showing the record added in step 2, click the Add record and get the balance.
    A new screen to add a new record opens with the value for Balance as of Yesterday populated. Screen showing the Balance as of Yesterday button
  4. Change the date, enter the deposit and withdrawal amounts, and then save the record. Screen showing the retrieved data for Balance as of Yesterday

When you add a new record the next day, today’s total balance will be retrieved into the Balance as of Yesterday field.