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

Workflow calculate all fields

teros
Registered: Feb 3 2008
Posts: 21

I'm preparing a form for users that have drop down boxes 1-7 for each category I am wondering how I tally up all of the items per category and then do a grand total then have the result's pass to a confirmation page??? it will then be emailed think I've figured out most of it except the totalling of the items and passing from one page to another.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
So you're counting the number of pull down boxes that have had something selected on them? Do the pulldowns include a non-entry, or a clear button?

Anyway, an empty value will be either an empty string or null. So all you need to test for are these values.

You could put code like this in the calculation event for the "Grand Total" field.

var count = 0;

cont += (d1.rawValue == null || d1.rawValue.length == 0)?0,1;
cont += (d2.rawValue == null || d2.rawValue.length == 0)?0,1;

etc.

If you want to copy the value from one field to another you have 2 options.

1. Give the fields the same name and global binding. This can be a problem if another binding is needed.

2. Do the assignment explicitly in the target fields calculation event. i.e. to copy from Feild A to Field B. Place this code in B's calculate event.

FormCalc: (Very simple, just the Field Name)

A

JavaScript:

this.rawValue = A.rawValue;

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

teros
Registered: Feb 3 2008
Posts: 21
The drop down boxes have numerical numbers is basically a rating system 1-7 so for each catagory would need a grand total and a complete total at the end. wondering as well how would i get this to flow or be on a diffrent page?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Well this is even simpler. You can do it with the FormCalc "Sum()" function. If you gave all the pulldowns the same name it would be even easier.

Here is the "Calculate" script for a colum sum where all the dropdowns have the name "Rating", and are in a subform called "Category1".

Sum("Category1.Rating[*]")

You'll find more info in the formcalc reference on this site:

http://kb.adobe.com/selfservice/viewContent.do?externalId=330467&sliceId=1

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

teros
Registered: Feb 3 2008
Posts: 21
Sorry would i do this via the xml source or? basically the main issue i am having is were to actually do this could show you the document i am working on to show you.

I've renames most of the columns to Man for the 1st categaory
teros
Registered: Feb 3 2008
Posts: 21
hey mate so far i've been able to grab one of the template forms and have added the part in but cant figure out what to do from hereSum(Man[*])
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You're better off using the scripting window in LiveCycle designer to enter code. It makes sure the XML is written correctly.

Is what you've done so far worked? It looks right.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

teros
Registered: Feb 3 2008
Posts: 21
No i am doing it exactly from a template and is not working
here is the xml for the total area

<?templateDesigner StyleID aped0?>99999Man1 + Man299999and mouse over?


Or you could check out what i am working on heres a direct link thanks for the help Thomp sorry i'm so useless with this only been doing this for 1 day so far.
http://teros.mine.nu/Self%20Assessment%20Profile2.pdf
teros
Registered: Feb 3 2008
Posts: 21
as you can tell by my script above i've changed only 2 of the drop down boxes to be named Man1 and Man2
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
For one day you are doing brilliantly!! But you really need to use both the Hierarchy window and the Scripting window. Don't edit the XML directly unless you really know what you are doing.

The syntax in your previous Sum script is correct. It's highly likely that you have the SOM Path wrong. That's what the hierarchy window is for. You need to get the SOM Path from the "Total" field to the "Man" fields correct. For example. If the field names are "Man1" and "Man2" then your calculation above is correct. But if Man1 and Man2 are in a different subform it is incorrect and the subform name has to be in the SOM Path, i.e., for a subform named "Category", "Category.Man1 + Category.Man2".

Use the URL I provided earlier to download the FormCalc, SOM, and XFA Object References/Guides. These contain everything you need to know about scripting in LiveCycle. Although they are not the easiest to understand.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

teros
Registered: Feb 3 2008
Posts: 21
thanks mate think part of it is actually find the things your refering to as well SOM path if you check out the link to what i am working on you'll notice that everything is within the same form but the form goes across multiple pages would this be also wrong would i need to do the script as page1.Man1 + page2.Man2?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, if the form breaks across multiple pages then it's likely, but not always true, that each page is a different subform and that you paths will have to be changed to accomodate this. But the only way to know is to look at the hierarchy window. If this window show un-named subforms, then name them.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script