GRW – Expression editor syntax

by Support Team

We had a support call recently where a user was having trouble coming up with the correct syntax in the Expression Editor in Genero Report Writer

They had a color property set to an expression such as

record.column.value<0?COLOR.RED:COLOR.BLACK

and were trying to use a similar expression in the bold and italic properties.  They were trying syntax such as

record.column.value<0?BOLD:NULL

which is incorrect.

The key thing to note with the expression editor is to understand what type of value is expected.   Any color property is expecting a value of type color http://www.4js.com/online_documentation/fjs-gst-manual-html/#c_grd_properties_color.html .  The color type being http://www.4js.com/online_documentation/fjs-gst-manual-html/#c_grd_ClassColor_001.html

The Bold or Italic properties are expecting a boolean http://www.4js.com/online_documentation/fjs-gst-manual-html/#c_grd_properties_fontBold.html.  The boolean type being defined http://www.4js.com/online_documentation/fjs-gst-manual-html/#c_grd_ClassColor_001.html

So when entering a value in the expression editor, note what type is expected in the property documentation and ensure that your expression returns a value of that type.  In this case the correct syntax depending how verbose you wanted the expression to be was one of...

record.column.value<0
record.column.value<0?Boolean.TRUE:Boolean.FALSE
record.column.value<0?TRUE:FALSE