Expressions in properties / Expression examples |
You want to check whether a field contains a value, is empty, or is null and act accordingly.
For this example, the data source includes the field orderline.order.contact, and the field is a STRING. The field either contains a value, is an empty string, or is null.
orderline.order.contact.trim().length()>0This expression will evaluate to either TRUE or FALSE.
orderline.order.contact.trim().length()==0
orderline.order.contact.isEmpty()==TRUE
orderline.order.contact.isNull()==TRUE
Expressions that evaluate to TRUE or FALSE can be used in the Visibility Condition (visibilityCondition) property. If the expression evaluates as TRUE, then the instance of the element will appear in the report. If the expression evaluates as FALSE, the instance of the element (to include all its children, i.e. the entire element tree) is removed from the report. If you are using relative positioning, all sibling elements after this element in the report structure shift accordingly, reclaiming the space that the element would have occupied.
orderline.orders.contact.trim().length()>0?orderline.orders.contact:""In this expression, the expression evaluates to TRUE when the length of the trimmed field is greater than zero and the field value is printed (to include any leading or trailing spaces). If the length is not greater than zero, the field is identified as not having a value and an empty string is printed; the vertical allocated space for that field remains in the report.
orderline.orders.contact.trim()
DEFINE field1 CHAR(5), DEFINE field2, field3 STRING LET field1="ABC" -- you end up with "ABC " LET field2="ABC" -- you end up with "ABC" LET field3="ABC " -- you end up with "ABC ", as explicitly specified