It may be necessary to perform an operation if a field is empty. An example would be to set the print attribute of a label field to false if the corresponding value is not passed in the data. Below are two examples of how this can be accomplished and some issues that can be encountered.
Examples
Normally you would assume that if the value is not passed in the data that you could use the following conditional:
conditional evaluating null
var fieldName = String(label.fields.field.(@name == 'INPUT').@data); // INPUT is not given a value at print time
if (fieldName == null)
{label.fields.field.(@name=='LABELFIELD').@printingField=false;}
The above conditional would evaluate as false and 'LABELFIELD' would still print.
However, when the Java script engine is run, and all the variables are created as "empty", the following conditional would evaluate as true and 'LABELFIELD' would not print.
conditional evaluating empty
var fieldName = String(label.fields.field.(@name == 'INPUT').@data); // INPUT is not given a value at print time
if (fieldName == "")
{label.fields.field.(@name=='LABELFIELD').@printingField=false;}