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

Brand New with Calculation Question

Avatar

Former Community Member
I am using Live Cycle Designer to design a new client application. Fairly simple format. I have a column of numeric fields that I need to add. Very similar to a simple excel SUM. How do I do this?
4 Replies

Avatar

Former Community Member
Hi Adam,

Unfortunately, it's not quite as simple as excel to sum fields using Designer - it's all about scripts. You have to take care of a few things first: creating your numeric fields, naming those fields, and adding scripts to those fields. The Purchase Order form in Designer's samples is a good example to follow.



Here's a basic adding example if you're starting from scratch:



You have two fields you need to add: 1) Apple and 2) Orange = 3) Pear. All three items need to be "numeric fields", value/type "calculated, user can override", binding set to normal. Now, viewing your script editor for the "Pear" field, use the following script:



sum (form1.Apple, form1.Orange)



The above script again goes in your script editor, function "calculate" and language is formcalc. You'll obviously need to change the path names for your Apple and Orange fields to match exactly what you have set up. If it's not EXACT, it won't work. Again, this is just a bare-bones idea of how to sum two fields.



Good luck!

Avatar

Former Community Member
Thanks, got it on my first try! One thing though, I set my Date Pattern as $z999.99 in my total numeric field and it is showing as 0750. No $ sign or .00? Any ideas?

Avatar

Former Community Member
It needs to be in your Display pattern, not your data pattern. Give that a try.

Avatar

Former Community Member
Thanks for that example!



I am new to scripting & I got it on the first try too. Goes a long way to helping with my form for QA.



Thanks again!