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

If then else statement calculate event formcalc or JavaScript

puppygirl39
Registered: Sep 22 2008
Posts: 12
Answered

I am trying to have a decimal field called Management that can make the following calculations with two fields ManagerScore and EmployeeScore.

if ManagerScore = 0 then EmployeeScore *.40
else
(ManagerScore + EmployeeScore) *.40/2

I have tried every possible combination that I can think of in the calculate event using FormCalc or JavaScript and failed every single time. Please help!!!!

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
In FormCalc the equality operator is "==".

The syntax of the "if" statement:

if ( simple expression ) then
list of expressions
elseif ( simple expression ) then
list of expressions
else
list of expressions
endif

So you could code


if (ManagerScore == 0) then
EmployeeScore *.40
else
(ManagerScore + EmployeeScore) *.40 / 2
endif

There is more information about FormCalc and JavaScript in the 'Scripting Reference" under LiveCycle Designer's menu "Help" option. Make sure all your variable names are spelled and capitalized correctly,

George Kaiser

puppygirl39
Registered: Sep 22 2008
Posts: 12
Thank you so much it worked!!!! I do have another question hoping you could help.

Performance Score is the total of five fields. Score 1,2,3,4,5. I thought everybody was going to have 5 scores but I was told this morning that some people can have 3 or 2 etc...

I am using the following code in the PerformanceScore Field
avg(Page2.Score1, Page2.Score2, Page2.Score3, Page2.Score4, Page2.Score5)
which works fine if everybody has 5 scores but if the employee only has 3 scores it should divide the total score by 3 and not by 5.

I tried something like this but I got no where

var Perfcount

Perfcount = Count(PerfCount)
{
if Page2.Score1 == 0 then else 1
else if
if Page2.Score2 == 0 then else 1
else if
if Page2.Score3 == 0 then else 1
else if
if Page2.Score4 == 0 then else 1
else if
if Page2.Score5 == 0 then else 1
end if
}

(PerformanceScore \ count)*.60