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

could someone help me with formcalc?

paalllikko
Registered: Jun 16 2009
Posts: 30
Answered

I have made a form that has sumfield that calculates other fields together. Now I would like to have a field that could have some kind of IF function, it should check if the sumfield value is e.g. under 10, between 10 and 20, between 20 and 30 and i would like to give an different text answer to each of those options?

How could I do this, what kind of formula I should write, I'm very new with this formcalc or javascipt.

My Product Information:
LiveCycle Designer, Windows
hcorbin
Registered: Aug 11 2009
Posts: 57
You can start with Designer Help. Look under the Scripting topic
Scripting > FormCalc User Reference > Language Reference > Expressions > If expressionsThere are a few examples that should help you get started.

Cheers
Hélène
paalllikko
Registered: Jun 16 2009
Posts: 30
thank you, i think that it will help, but what is the right "show" selection??? calculate, initialize, validate, enter, exit, mouse click......???
hcorbin
Registered: Aug 11 2009
Posts: 57
Try writing the script on the calculate event of the field displaying the different text answers.

There is more information about the scripting events in the Help here
Scripting > Scripting Using LiveCycle Designer ES > EventsRegards,
Hélène
Jimmy0306
Registered: Dec 11 2008
Posts: 32
If you have two Fields one that has the number and the other you want the response...In FormCalc, you would want to calculate the following expression. The "Number" is a NumericField I called Number.

If(Number<10,"Less than 10",If(Number ge 10 and Number le 20,"Between 10 and 20",If(Number ge 20 and Number le 30,"Between 20 and 30",If(Number>30,"Greater than 30",""))))I have used upwards of 100 nested if statements in a single field with no problems.
paalllikko
Registered: Jun 16 2009
Posts: 30
Well, I have tried to manage this problem of mine, but cant make it work, this is a script that I have entered to a text field (Priorisation is the name of the text field):

if ( Sum > 30 ) then Priorisation = "Priority I" elseif ( Sum > 20 and Sum < 30 or Sum = 30 ) then Priorisation = "Priority II" elseif ( Sum < 20 or Sum = 20 ) then Priorisation = "Priority III" endif;
hcorbin
Registered: Aug 11 2009
Posts: 57
Yes I'm getting a FormCalc error when I preview the form. The expression verifying the value of Sum is incorrect. Use the equality operator == instead of the assignment operator =.

if ( Sum > 30 ) then $ = "Priority I" elseif ( Sum > 20 and Sum < 30 or Sum == 30 ) then $ = "Priority II" elseif ( Sum < 20 or Sum == 20 ) then $ = "Priority III" endif

Regards,
Hélène
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Simplify the test:

// greater than 30if (Sum > 30) then"Priority I"// > 30 done now test for greater than 20elseif (Sum > 20) then"Priority II"// > 20 done now test for greater than 0elseif (Sum > 0) then"Priority III"// less than or equal to zero is now leftelsenullendif

Or use only the 'and' operator along with a different comparative operator:
if (Sum > 30) then"Priority I"elseif (Sum > 20 and Sum <= 30) then"Priority II"elseif (Sum > 0) and Sum <= 20) then"Priority III"elsenullendif

And if you absolutely need to use the 'and' and 'or' operators in the same logical statement, set the priority by grouping the comparisons in the order they are to be performed in:
if (Sum > 30) then"Priority I"elseif (Sum > 20 and (Sum < 30 or Sum == 30) ) then"Priority II"elseif (Sum GT 0 & (Sum LT 20 | Sum EQ 30) ) then"Priority III"elsenullendif

George Kaiser

paalllikko
Registered: Jun 16 2009
Posts: 30
thank you very much for your answers, those answers really helped a lot.

Santtu From Finland