Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Coding & Calculating like Excel

Avatar

Former Community Member

I have been using L.C.D for about 2-weeks now . . . and I've taken to it fairly quickly.

What I don't understand, is how do I create formulas & make things "talk" to each other.

I'm making a "Purchase Requset" form for a University and I've come to a field.  I ask the user to enter the "Unit Price", "Quantity" & "Shipping Cost".  I would like to then have a conditional check boxes, one that asks if this is a food item (tax exempt).  Also, if the user enters the "Payee State" as "AZ" then I'd like the form to automatically calculate the applicable state tax rate of 9.30%.  I'd like to have all of this calculate into the "Complete Total" box.

This kind of work is WAY over my head, any help is GREATLY appreciated.

-Alex.

alesnyde@uat.edu

4 Replies

Avatar

Level 4

Easiest way would be to have a calculate script on the Complete Total box that adds up all the other fields and if the checkbox is checked, then you can add the tax.  So check out the calculate script and also having some Javascript/FormCalc knowledge would help.

Avatar

Level 1

Alex,

Try plugging in this using JavaScript under the calculate function. "subTotal", "CheckBox", grandTotal" will need to be changed to match your current Binding name in the object pallet.

this.rawValue

= subTotal.rawValue

if (CheckBox.rawValue == true)

grandTotal.rawValue

= subTotal.rawValue * .093;

else

grandTotal.rawValue

= subTotal.rawValue;

Aaron

Avatar

Level 1

This script should be used on your "Total" field, forgot to mention that.

Avatar

Former Community Member

Here is the code I actually ended up using . . . it works GREAT!

thanks for all the help!

if ((type == 5) or (food == 1) or (state == 0))

then

    total = round ((price1 * quantity1) + (price2 * quantity2) + (price3 * quantity3) + (price4 * quantity4) + (price5 * quantity5) + (price6 * quantity6) + (price7 * quantity7) + shipping, 2)

else

    total = round ((price1 * quantity1) + (price2 * quantity2) + (price3 * quantity3) + (price4 * quantity4) + (price5 * quantity5) + (price6 * quantity6) + (price7 * quantity7) + (shipping) * 1.093, 2)

endif

Is there a way to attach my completed form?

-Alex.