1
0
-1

Hi - learning the product and had a question regarding the speadsheet. how do we include a value in the main form in the calculation within the spreadsheet? 

I have an amount in the main form. 

in the spreadsheet,  I would like to multiply it by a value in a cell. is that doable?

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi, let said you have a field id named "disc" and your spreadsheet column id named "amount" and "total". You want the "total" column value auto calculated by the value of "amount" minus the discount calculate by the percentage value in "disc" field.

      In your spreadsheet, you can configure your formula of "total" column with

      calculateTotal(amount)

      the calculateTotal is a javascript function you going to implement with a Custom HTML element with following code.

      <script>
          function calculateTotal(amount) {
              var disc = FormUtil.getField("disc").val();
              if (disc === undefined || disc === "") {
                  disc = "0"; //set a default
              }
              return amount * (100 - parseFloat(disc)) / 100;
          }
      </script>
        CommentAdd your comment...