Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Script Syntax Error 30008 and Multiple If(x and y and...)s

Avatar

Level 2

I am trying to modify an existing form (that was working well) to allow calculation of a set of values in the event there is a partial year included in the term being analyzed. It is all kinds of a headache as the 'logic' and 'execution' to get there are not as simple as an Excel calculation.

In trying out some possible solutions, I have begun having calculation-stopper Script Syntax Errors, and I can NOT figure out the source of the problem. In my Report palette warning tab, I get repeated warnings such as (but not limited to!)

Object: StepRent2  Description: Error: syntax error near token 'Step2' on line 2, column 6   Type: Script Syntax Error   Code:30008

I have no idea what Code 30008 references/ means. I have spent an inordinate amount of time searching for a list of warning codes that include 30008 so I have even the slight clue of knowing what to stare at. I would greatly appreciate if someone could let me know where the Code list is hidden.

I think I have more fundamental issues with my coding attempts, although logically these should work -- but they don't. I would also appreciate if someone could point me to a fuller example of how to work with multiple IF conditions and the proper use in FormCalc for "and" in the IF logic world.  I am tripping over setting up this extra complexity in at least 4-5 numerical fields in each subform enveloping a particular "year" number.

Already for each calculation after year 1, there is a formula which is to the effect of (Value for year 1 * escalation%) + Value for year 1 = Value for Year 2. That formula cascades along through each year with a value being based on an escalation of the prior year. The ripple is that the calculating needs to 'stop' based on the number of years in the manually-entered Term. I figured this out, undoubtedly the hard way, by creating in each cell being calculated a FormCalc script that states If (Term.rawValue >{the number for the prior year}) then the $.rawValue for the particular year = (prior year's value.rawValue * escalation%.rawValue) + the prior year.rawValue. It was tedious, but it works.

Now I've added a numerical cell adjacent to the Term cell to reflect the percentage of the year = the number of months in the partial year (e.g. 8 months = .67) -> the Partial Value. The need is simple -- take the full year values from the calculation of the final-partial year (which already shows up due to that year being > the prior year) and multiply those by the "Partial" value. But the execution is challenging me and I am killing any hope of figuring this out by generating Script Syntax Errors (with mysterious Code numbers) that I just don't know what the problem is.

I'm setting this up so that IF the Term is >{prior year}, the Partial Value is >0, and the total of the costs in the following year are 0, THEN ... do the formula for the full year for the final year and then multiply it by the Partial Value. It is not working.

To try to break it down, I added numerical cells for each test year- into which I entered the formula for the full year (a Stepvalue), then in the corresponding value in the main grid I set that that $.rawValue = the Step value * the Partial Value. Logically that is exactly what I need to have happen, even if a labor-intensive way to get there. Yet.... Script Syntax Error.

Every. Time. I. Try.

I'm at wit's end, but so hopeful someone will be able to spot the error of my ways, the flaws in my logic/illogic, and won't mind pointing me in the right direction. Most obviously I am not a coder, though I do try to learn and extrapolate.

Many thanks to anyone who stuck with my lengthy description long enough to get this far. Anyone who can help gets gold stars!

Thanks,

L-E

0 Replies

Avatar

Level 10

Are you able to post the form for people to look at? Would make things a lot easier.

You can't post forms to the forum so you'll need to use acrobat.com, dropbox.com or something like that to host the file.

Avatar

Level 2

Oof! Don't I know it! However... I apologize in advance! I've posted 2 versions. One is the form that DOES work -- but doesn't provide for a partial year:

https://files.acrobat.com/preview/807a07e3-1e43-44a0-aec8-4e60c062accc

The other is where I am totally stalled out and erroring my syntax. I am obviously in beginning stages with this one, but it includes where I was trying to solve my problem by having a 2-step workaround, and I added the 'secret boxes' numerical fields for yrs 2 and 3 (just to work out the problem).

https://files.acrobat.com/preview/843f7aa2-63b3-4d5a-b712-060c8cffe05b

Thanking you in advance for even looking. I'm stymied. It is so much work to be ignorant!!!

L-E

Avatar

Level 10

I can get the first file but the second is generating a page not found error.

Avatar

Level 10

Not working either. You have to share the file and publish it - after you share from the menu the pop-up should ask you to publish the file as well.

I don't know why they don't make that a one-click share...

Avatar

Level 2

Now if only … IT WORKED… as a form ☺

L-E

Avatar

Level 10

Ok, so you've got a lot of syntax problems to start with.

If you have the console turned on in Acrobat (CTRL-J to open the console

window) it will show you the errors. It's good to set Acrobat to pop up the

console on encountering errors - go to Edit>Preferences>JavaScript and turn

on "Enable interactive console" and "Show console on errors and message".

The last setting will automatically open the console and show errors when

encountering them (like when opening the file).

The error messages will point you to where a problem is but it's not

necessarily all that clear what the problem is. You can also try using the

Check Script Syntax button in the Script Editor (the book icon with the

green checkmark), it's not very smart though but will help you find missing

brackets and other errors but you still need to figure out what's wrong.

You're mixing JavaScript and FormCalc syntax together but it's mostly

misplaced brackets and punctuation. These won't hurt but when using

FormCalc you don't need to use semicolons at the end of lines or .rawValue

to access field values, makes for cleaner script.

The following documents are good reference:

FormCalc User Reference

http://help.adobe.com/en_US/livecycle/9.0/FormCalc.pdf

LiveCycle Designer Scripting Basics

http://help.adobe.com/en_US/livecycle/9.0/LiveCycle_Designer_Scripting_Basics.pdf

LiveCycle Designer Scripting Reference

http://help.adobe.com/en_US/livecycle/9.0/lcdesigner_scripting_reference.pdf

So, on first opening the file I get two errors:

Script failed (language is formcalc; context is

xfa[0].form[0].form1[0].TopPosition[0].AllYearsSForm[0].Year2[0].Rent2[0])

script=if(Assumpt.Term.rawValue >1; and Assumpt.Partial.rawValue >0.00;

and Year3.TEC3.rawValue =0.00); then

$ = Step2.StepRent2 * Assumpt.Partial;

elseif(Assumpt.Partial.rawValue =0 and Assumpt.Term.rawValue > 1)then

$.rawValue = (Year1.Rent1.rawValue * Terms.RentEsc.rawValue) +

Year1.Rent1.rawValue;

else

$.rawValue = 0;

endif

This is just a general script fail. There are a bunch of syntax problems.

You're mixing some JavaScript in with your FormCalc and have some other

problems. A big one that goes for JavaScript and FormCalc is assigning a

value vs testing a value - one equals sign is for assigning a value

(fieldName = 1) - two equals signs are for testing a value (if (fieldName

== 5)). And don't forget the "endif" at the end of a FormCalc if statement.

The script should look like:

if (Assumpt.Term > 1 and Assumpt.Partial > 0 and Year3.TEC3 == 0) then

$ = Step2.StepRent2 * Assumpt.Partial

elseif (Assumpt.Partial == 0 and Assumpt.Term > 1) then

$ = Year1.Rent1 * Terms.RentEsc + Year1.Rent1

//brackets not needed for math if you follow Order of Operation rules but

they don't hurt

else

$ = 0;

endif

Error: syntax error near token '$' on line 2, column 2.

Script failed (language is formcalc; context is

xfa[0].form[0].form1[0].TopPosition[0].Step2[0].StepRent2[0])

script=if(Assumpt.Term.rawValue >1; and Assumpt.Partial.rawValue >0.00;

and Year3.TEC3.rawValue =0.00); then

Step2.StepRent2.rawValue = (Year1.Rent1.rawValue *

Terms.RentEsc.rawValue) + Year1.Rent1.rawValue

Error: syntax error near token 'Step2' on line 2, column 6.

Another non-specific error, because of syntax errors on the first line it

doesn't know what's happening on the second line. It's saying "error near

token '$'" when there is no $ is because it's referencing the field the

script is on (Step2.StepRent2). $ is shortcut for the current field which

it says a little more clearly in the Error message on the last line.

if (Assumpt.Term > 1 and Assumpt.Partial > 0 and Year3.TEC3 == 0) then

$ = Year1.Rent1 * Terms.RentEsc + Year1.Rent1

endif

But on fixing that we get:

Script failed (language is formcalc; context is

xfa[0].form[0].form1[0].TopPosition[0].Step2[0].StepRent2[0])

script=if (Assumpt.Term > 1 and Assumpt.Partial > 0 and Year3.TEC3 == 0)

then

$ = Year1.Rent1 * Terms.RentEsc + Year1.Rent1

endif

Error: accessor 'Year3.TEC3' is unknown.

This means that the script can't find "Year3.TEC3". This is because

"Year3.TEC3" is under a different subform structure so it needs the path to

the subform it's under which would be "AllYearsSform.Year3.TEC3".

The easiest way to get the full path needed to other objects in the Script

Editor is to CTRL-click on the object in the Design View window. What you

need to do is scroll the display until you can see the object you want then

click in the Script Editor where you want the object reference then press

and hold the CTRL key and click on the object - when holding CTRL down and

moving over the Design Window the mouse cursor will change to a "V" when

you are over a valid object.

CTRL clicking will give you a Relative SOM path and CTRL-SHIFT clicking

will give you an Absolute SOM path:

in this case relative is "AllYearsSform.Year3.TEC3" and absolute is

"form1.TopPosition.AllYearsSForm.Year3.TEC3".

if (Assumpt.Term > 1 and Assumpt.Partial > 0 and AllYearsSForm.Year3.TEC3

== 0) then

$ = Year1.Rent1 * Terms.RentEsc + Year1.Rent1

endif

On that last fix there are no more errors on opening the form.

Hopefully that gives you something to work with!

Message was edited by: Jono Moore - email borked my nice formatting.

Avatar

Level 2

Oh, my goodness!!! You are beyond exceptional!!! That will definitely give me the flashlight to shine on my (MANY) issues. That is also some of the best, clear explanation I have seen as I look (constantly!) for help that reads simply for me as a non-coder/ non-tech imagination person. Thank you for that, and thank you for your help and guidance!

I appreciate you SO very much!

L-E