Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Addinstance TOTAL


Former Community Member
I am making an estimate sheet with an add/ remove instance subform labeled "Instance". I can add and remove the forms with no problem. Within the instance is a numerical field called "Price". I need to SUM total the Price field on every instance that I add. Also, if I remove one of the instances, I need it to deduct from the total (I read there were errors with this).

These are the scripts I have in each field:





// Verify at least one instance of the numAmount field exists.

if (exists(detail[0].numAmount) == 1) then






I might be off by a few characters. I am a beginner with javascript/ livecycle, so I pretty much Frankensteined this code. Addinstance isn't something I can accomplish with Acrobat Pro alone. So I'm thrown into the fire w/ Livecycle.

I have searched in and out of google, this forum and livecycle help. I can't figure this problem out. Help will be extremely appreciated!
2 Replies


Level 1

It seems you're using Form Calc, and i think you should use JavaScript instead. You may have to do one of the following:

(a) code the "click" event in your add/delete instance button

(b) place your code in the "calculate" event for the sum field

You can use both FromCalc or JavaScript (i prefer JavaScript).

Refere to the "Purchase order" sample, use the "Dynamic interactive" variation. It has the same properties you want. The samples are on the LiveCycle Designer's installation directory.

Hope this helps.


Level 3


Please download the sample form from here.  https://acrobat.com/#d=Xxh9tEdKkYuByNDdKR4Geg

1. Place the below code  in the calculate event of your total field.


TotalField.rawValue = Sum(instance[*].price)

Make sure the script selected under language is formcalc.

Also to  Verify at least one instance of the numAmount field exists.

You can check the object panel of the subfom and under Binding TAb you can check the option "Repeat subform for each data item with Min count 1."