Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Calculating fields

Avatar

Former Community Member

I am having a problem figuring out how to calculate several fields so that they appear as a sum in another field.

Example - I have three fields - Quantity, Unit Cost and Total. I want it so that when I enter a number in the quantity, it will times that number by the unit cost and enter it automatically in the Total field. (The quantity and total are numeric fields, and the unit cost is a text box that cannot be edited, as this will be sent to other people as an order form.)

I have tried it with a form that I exported from Excel, and I can do it in the 'Add or edit fields' tab. However the form I am working on has been created in LiveCycle and there is no option to add or edit fields.

Can anyone give me some help? I can give more detail if necessary

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 2

Play around with the PATTERNS for the field - the display option under the FIELD tab.  It has quite a few different ways it will display that data.  With and without the $, etc .........  I'm sure one of those will do the trick.

View solution in original post

7 Replies

Avatar

Former Community Member

The unit cost shoudl be a numeric field as well. Then in the Total Field on the Calculate event you can enter this FormCalc formula:

QuantityFieldName * UnitCostFieldName

Paul

Avatar

Former Community Member

Thanks very much for your help, I couldn't figure out the forumla either. Is there a way I can lock the unit cost field so it cannot be edited by anyone else, but leave the other fields open?

Avatar

Former Community Member

Set the UnitCost field as calculated ReadOnly in the Type dropdown on the Object/Value palette.

Paul

Avatar

Former Community Member

Another question:

I am doing an order form, and I would like it so that I can calculate the VAT on a total order (which I have a numeric field for.)

Is there a way of calculating my 'Net Total' numeric field by 17.5% so that it shows up in the VAT field?

EDIT: I have found a way of doing this, although now I cannot figure out how to limit the numeric fields to two decimal places, is there a way to do this?

Avatar

Level 2

Be sure your field is defined as a Decimal Field, then, in the Object tab, check Limit Trailing Digits and set the value to 2.

Avatar

Former Community Member

I have limited the trailing digits and it has worked fine, but I am now stuck with one more problem. When a number is calculated that looks like this - 25.50, it leaves out the '0' at the end and displays it as 25.5. I need to be able to show the second decimal place

Avatar

Correct answer by
Level 2

Play around with the PATTERNS for the field - the display option under the FIELD tab.  It has quite a few different ways it will display that data.  With and without the $, etc .........  I'm sure one of those will do the trick.