Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Calculating tax based on user input to check-box and displaying result.

Avatar

Level 3

Thanks to Jono & WhyIsThisMe for getting me started on my first scripting project! I am almost there with my purchase requisition form (90% made from the tutorial).  Everything works except for the Taxable column

form.JPG

I can't figure out the correct syntax for checking the value of the check-box in the Taxable column and then doing the calculation for Tax based on the User entry in the Tax% field

(total * stateTaxPercent / 100)

I basically want to do the calculation only when the taxable = 1 and display the cumulative tax in the Tax field.

Should I use mouseup as the trigger to perform the tax calculation, and save the result as a variable and display variable in Tax field? Then if another Taxable box gets checked, I could add the new calculation to the variable. Not sure if this is an elegant way to get there.

?

1 Accepted Solution

Avatar

Correct answer by
Level 7

I would put the following in the change event of each taxable checkbox (in formcalc):

if ($ == 1) then

tax = tax + (amount * 0.0825)

elseif ($ ==0) then

tax = tax - (amount * 0.0825)

endif

(where 'tax' is whatever you have called your total tax box and 'amount' is whatever you have called your unit price box).

View solution in original post

2 Replies

Avatar

Correct answer by
Level 7

I would put the following in the change event of each taxable checkbox (in formcalc):

if ($ == 1) then

tax = tax + (amount * 0.0825)

elseif ($ ==0) then

tax = tax - (amount * 0.0825)

endif

(where 'tax' is whatever you have called your total tax box and 'amount' is whatever you have called your unit price box).

Avatar

Level 3

Thanks! I modified it to this: (and it works). The tax rate is a user entry.

if ($ == 1) then

stateTax = stateTax + (unitPrice * quantity * stateTaxPercent / 100)

elseif ($ ==0) then

stateTax = stateTax - (unitPrice * quantity * stateTaxPercent / 100)

endif

Thanks again!