Conditionally include static text in DOCX template for non-empty fields


I need to be able to include static labels into a report for non-empty fields. Labels should not be included in a report if a field is empty. For example, ‘Genre:’ label should be included if ${} is not empty, otherwise it should be omitted.

Thank you,
Dmitriy Melikov

Hello @dmelikov,

You can create a band with a groovy-script and format the output. Or you can fully form the text and transfer it to one tag, and if formatting is required, use the html formatter (Форматы значений полей - Платформа CUBA. Генератор отчётов).

Report templare:

Band (Dataset - groovy):


def groupId = params['group'].id

def group = dataManager.load(Group.class)
                       .query('select e from sec$Group e where = :groupId')
                       .parameter('groupId', groupId)

def result = "Name: ${}"

if(group.parent != null) {
    result = [['name': "Name: ${}",'parent':"Parent: ${}"]]
} else {
    result = [['name': "Name: ${}"]]

return result


Report: (11.0 КБ)


Hello Nikita,

Thank you for getting back to me.
I will follow your recommendation.

Best regards,
Dmitriy Melikov