2

I have Invoice object which contains some fields like invoice number, date, customer etc.., I like to print my invoice data for that I used opensagres.xdocreport api. In this process I used Velocity Template Engine. If invoice object has no data for some fields then, I got output like below explained.

I used my template like this.

<h1>Invoice No : $Invoice.number<h1>

<h1>Date : $Invoice.date<h1>

Expected output

Invoice No : INV003

Date : 11-08-2015

but I got like this

Invoice No : INV003

Date : $Invoice.date

But I want space if no data for date. plz let me know the solution.

Semih Eker
  • 2,389
  • 1
  • 20
  • 29
Siva kumar
  • 215
  • 4
  • 13

2 Answers2

1

Your problem is the same than Velocity nulls and empty strings. In other words try to write :

Date : $!Invoice.date
Community
  • 1
  • 1
Angelo
  • 2,027
  • 13
  • 17
0

Invoice.date must be an Object not a Date and you can check the date before generate. If it's not null, then Invoice.date = date, but if null then Invoice.date = "" (String).

Let me know if I helped you.

nabu
  • 1
  • 1