Skip to main content
April 4, 2022
Question

Handling condition in freemarker docx template

  • April 4, 2022
  • 4 replies
  • 0 views

We have two fields drillTime and drillDateTime.

Condition:

If there is a value in drillTime print drillTime or if it is null

Print drillDateTime

[#if dmd.drillTime??]
${dmd.drillTime!""}
[#elseif dmd.drillDateTime??]
${dmd.drillDateTime??}

Above we used in template but its not working correctly.

Its printing drillTime if there is a value in it  and if it is null its not printing drillDateTime.

Note: drillTime is text and drillDateTime is date and time type.

 

4 replies

mathieud0001
April 4, 2022
April 5, 2022

Thanks for your reply but the link you provided is not helpful for me.

acaciob0002
April 6, 2022

Hi vamsikrishnac0001,

In my understanding, when you are using an Else IF condition, you need to also provide an ELSE, can you please have a look in the code below and see if it can help you?

[#if dmd.drillTime?has_content]
${dmd.drillTime!""}
[#elseif dmd.drillDateTime?has_content]
${dmd.drillDateTime??}
[#else]
Add the condition for the else
[/#if]

Regards,

Acacio B.

April 6, 2022

Thank you very much [mention:b389a349840947d58879708f8b0249f2:e9ed411860ed4f2ba0265705b8793d05]

I have already figured out the code.

  1. [#if dmd.drillTime??]
    [#if dmd.drillTime!=""]
    ${dmd.drillTime!""}
    [elseif dmd.drillDateTime??]
    ${dmd.drillDateTime!""}
    [/#if]
    [/#if]