Issue when pressed submit button

Hi All,

I have a simple audit form as interface used for auditing between members.

I am trying to configure as below,

    When details are entered and pressed on submit that need to save the details in database which is happening successfully except a column regarding balance left.

which will be calculating the balance left with the previous row.

example:

Money = 1050
price in row 1 = 50; balance_left in row 1 = 1000; 
price in row 2 = 100; balance_left in row 2 = balance_left - price= 900
price in row 3 = 100; balance_left in row 3 = balance_left - price= 800

Please let me know how can we configure this in interface when clicked on submit button

  Discussion posts and replies are publicly visible

  • Hi there,

    On submit button, you can run a forEach() loop to iterate through the list of variables (CDT), and for each item, you can use the sum of all the previous 'price' values to generate the balance left value. Please find a snippet below. 

    a!localVariables(
      local!money: 1000,
      local!items: {
        { price: 500 },
        { price: 70 },
        { price: 10 },
        { price: 200 }
      },
      a!forEach(
        items: local!items,
        expression: {
          price: fv!item.price,
          balance_left: todecimal(local!money) - sum(
            todecimal(
              index(
                todecimal(local!items.price),
                enumerate(fv!index) + 1,
                {}
              )
            )
          )
        }
      )
    )