These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

FormCalc Help

pd417
Registered: Apr 1 2008
Posts: 10

I realize this topic has probably been addressed numerous times, but unfortunately, I can't find a definitive answer. I just created an interactive form for a client in LiveCycle 8.0. that has numerous individual columns that need to be totaled. I read the help file for FormCalc and while the math part makes sense, how to execute it doesn't. If this was a spreadsheet, I would create a formula and tell it which columns to add. But in LiveCycle/FormCalc there are no rows or columns to point to.

Creating the formula seems easy enough, but how do I tell the formula which numeric fields to add?

Thanks..

My Product Information:
LiveCycle Designer, Windows
hiddengraphics
Registered: Mar 19 2008
Posts: 39
This may help
I use an older version of Acrobat. I do not have livecycle/formcalc, but I can do what you want to do in the following way:

I name each field as a separate field[ product01,product02, etc]
Then I use simple javascript to do the calculations. I use 'if' statements to eliminate writing zeros unless I specifically want them visible.
pd417
Registered: Apr 1 2008
Posts: 10
Thanks for the reply. I'll give your suggestion a try and let you know how it goes.

**UPDATE**

I tried your suggestion and named each field (in fact, I just used the default names given) and added each together. It worked and I was able to total the columns. The only problem is some of my columns have 15-20 fields in them, so setting up the expression of:

NumericField1[3]+NumericField1[4]+NumericField1[5] etc can be a bit tedious.
Is there a way to sum a series of numbers without having to add each one individually? In Excel, it would be like this:

SUM (NumericField1[3]...NumericField1[15])
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
In version 8 LiveCycle Desinger provides "Scripting" reference under the "Help" meu option with examples of code and a descriptions of the builtin functions.

Look for 'Sum()".

George Kaiser

beachbumbali11
Registered: Mar 5 2008
Posts: 74
ok yes simple question gkaiseril is right as usal and he has helped me many times but hes not sharing the easy way to do it here just make sure all the fields in each colum or row are named the sam and make sure global is turned off then the form cal under calculation looks like this
$ = Sum(field1[*]) + Sum(field2[*])
if you look under the hieracrchy you will see that livecycle already gave them subnumeric names then the * denotes all fields in that node and like excel sum is a basic fnction
dont worry help in livecycle is the worst thing ever created by adobe there are gramatical errors every where and you cant even view it as a pdf go figure and they dont show proper syntax wait till you try using the java script help had me going in circles for days but god bless this forum, i have almost finished the form i was trying to build after a month
pd417
Registered: Apr 1 2008
Posts: 10
gkaiseril:

I tried the SUM function, and maybe I missed something, but I still had to list each of the individual fields. I would like to add a range of fields.

Example:

SUM(NumericField1[3], NumericField1[4], NumericField1[5]).

beachbumbali11:

I looked in the hierarchy view and was unable to find any other field names except the ones I listed above. Where are the subnumeric names?
So, in the example you gave, will it total a range of fields or do I still have to add them individually?
beachbumbali11
Registered: Mar 5 2008
Posts: 74
ok do a blank page to get the point real quick then apply to your real form
ok drag a single numeric feild on to the page
click on this item and while draging it down hold the control key to duplicate it
do it again look in the hiearchy pallet
now you will see the sequence in []
drag another numeric field from the library
this one should be numeriffield2 while the others are 1[0], 1[1],1[2].
still with me
ok click the numericfield 2 box and open the script editor under the calculate drop menu enter this make sure your in form calc under language
$=Sum(NumericField1[*])
hop to preview and test it
the $ means this field some say its not needed but i like to use it for clarity
so sounds like your new to this no worries better go the tutorial section of this site and start learning. But basic tip is this when building a table use text objects as the header colums and use the other feilds with no captions (layout pallet) then create a single row ie the first row shift click all the items and control drag down as many as you need this way the names will auto generate in order and stay aligned.
So on that same blank page drag out another numeric field this one should be 3 crt drag two of those down go back to number 2 and try this
$=Sum (Numericfield1[*], Numericfield3 [*])
check it doesnt work right not sure why but form calc doesnt identify the cells you have to add the sums like i listed above Sum(feil[*]) + Sum(feild[*]), why i dont get it is this
$Sum(Numericfield1[0], Numericfield1[1], Numericfield3[0]) works but this should be enough to get yoou going
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
pd417 wrote:
gkaiseril:I tried the SUM function, and maybe I missed something, but I still had to list each of the individual fields. I would like to add a range of fields.

Example:

SUM(NumericField1[3], NumericField1[4], NumericField1[5]).
All function names, properties, methods, field names, accessors, etc are all case sensitive. This means you have to exactly follow the capitalization. The same applies to syntax, if it is not correct the code will not work, although there is some variations allowed.

Your code should read:

Sum(NumericField1[3], NumericField1[4], NumericField1[5])

or

$.rawValue = Sum(NumericField1[3], NumericField1[4], NumericField1[5])

If you are going to add a column of "NumericField1" fields it is the whole column or nothing when you can use the "*" for the multiple reference.

Sum(NumericField1[*])

With the use of control loops one could cover a contiguous range of fields by specifying the starting, ending and increment for the element accessor.

George Kaiser

pd417
Registered: Apr 1 2008
Posts: 10
Thank you both for the assistance. I should have mentioned at the beginning of my post that I am new to FormCalc, so my apologies for the "newness" of my questions. I haven't programmed in years, and while it's familiar, it's still quite new.

I will put your advice to use later this afternoon and hopefully I'll get the results I am looking for! I'll let you know the outcome.
beachbumbali11
Registered: Mar 5 2008
Posts: 74
Yah thats what i meant to say i told you he knew more than he was saying his tips work well even though they are mostly over my head
AlScott
Registered: Nov 2 2007
Posts: 123
Hi pd417,
I've created a 'purchase' order that I think does what you want. Now - if there was a way of attaching it to this I'd be happy to send you a copy.