Expand my Community achievements bar.

Need a Quick Fix

Avatar

Former Community Member
Calculation I have;



----- form1.#subform[0].EvidenceLabel::calculate: - (FormCalc, client) -----------------------------



if (EvidenceYear == null) ;

then $.rawValue = "";

else $.rawValue = Concat(FileNumberClientID, "-", FileNumberCheckDigit, "-", FileNumberDate, "-") ;



Error I get:



Generating PDF Document...

Script failed (language is formcalc; context is xfa[0].form[0].form1[0].#subform[0].EvidenceLabel[0])

script=if (EvidenceYear == null) ;

then $.rawValue = "";

else $.rawValue = Concat(FileNumberClientID, "-", FileNumberCheckDigit, "-", FileNumberDate, "-") ;

Error: syntax error near token ')' on line 3, column 99.

Font Service: Default font typeface is Myriad Pro.

PDF generated successfully.



1 warnings/errors reported.
2 Replies

Avatar

Level 7
Have you read the LiveCycle documentation about Scripting and the "if" statement in FormCalc?



You are trying to use JavaScript syntax and not the FormCalc syntax. FormCalc also has the "HasValue()" function to detect empty fields.



if (HasValue(EvidenceYear) == false) then

$.rawValue = ""

else

$.rawValue = Concat(FileNumberClientID, "-", FileNumberCheckDigit, "-", FileNumberDate, "-")

endif

Avatar

Level 7
My mistake, LiveCycle does not use true or false for logical test, but uses 1 and 0.



if (HasValue(EvidenceYear) == 0) then

$.rawValue = ""

else

$.rawValue = Concat(FileNumberClientID, "-", FileNumberCheckDigit, "-", FileNumberDate, "-")

endif



A clearer way to write the code could be:



if (HasValue(EvidenceYear)) then

$.rawValue = Concat(FileNumberClientID, "-", FileNumberCheckDigit, "-", FileNumberDate, "-")

else

$.rawValue = ""

endif



Because you are using date field fields, you also might want to look at using the "formattedValue" property for the date fields so you do not get the entered string if it is different from the formatted display value.