calculation tip in spreadsheet (subform)

Confluence User - 18 May, 2018

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?

forms

1


18 May, 2018
confluenceUser
confluenceUser

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>
RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print