Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: Print if not empty?  (Read 5764 times)

darktorres

  • Newbie
  • *
  • Posts: 3
    • View Profile
Print if not empty?
« on: June 06, 2016, 06:35:24 am »
Hi, is there some way to only print text from datasource if it´s not empty?

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Print if not empty?
« Reply #1 on: June 06, 2016, 08:30:16 pm »
Hi, What do you mean only print text ?

darktorres

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Print if not empty?
« Reply #2 on: June 06, 2016, 08:35:47 pm »
In the databand is there some way to show a secondary value if it´s not null? Like: $D{db.price} + if(!$D{db.discount}.empty) $D{db.discount}

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Print if not empty?
« Reply #3 on: June 07, 2016, 01:31:19 am »
Code: [Select]
$S{if ($D{db.price}!="") $D{db.price} + " "+$D{db.discount}; else ""}

darktorres

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Print if not empty?
« Reply #4 on: June 07, 2016, 07:51:34 pm »
Thanks!

pasnox

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Print if not empty?
« Reply #5 on: June 22, 2016, 10:29:06 am »
Similary to this: empty fields, or not existing field in the actual query: how can we suppress the warnings ?
We have reports used by many customers, and sometimes some fields does not exists for one.
In this case we want to suppress the warning message but did not find any solution ?

Opened: https://github.com/fralx/LimeReport/issues/38
« Last Edit: June 22, 2016, 10:31:07 am by pasnox »

Subst

  • Sr. Member
  • ****
  • Posts: 450
    • View Profile
Re: Print if not empty?
« Reply #6 on: June 23, 2016, 08:33:33 am »
try to use external variables from your program. That determine need or needless printing

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Print if not empty?
« Reply #7 on: June 29, 2016, 11:03:37 pm »
I have added "Suppress absent fields and variables warning" parameter to report settings

pasnox

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Print if not empty?
« Reply #8 on: July 28, 2016, 02:14:27 pm »
Thanks!

Now the next issue :)
We can now quiet warnings for missing fields, but I did not find a way to give fallback values.
When a field is missing, it seems the custom script exit instead of simply return null value for the queried field:
Code: [Select]
$S{
    "$D{Marcel.pagnol}" === "" ? "$V{Marcel.pagnol}" : "$D{Marcel.pagnol}"
}

The data source Marcel and the field pagnol does not exists, though I have declared a custom variable Marcel.pagnol.

What I want is to fallback to my custom variable if the data source field does not exists.
Actually this throw: SyntaxError: Parse error
Any ideas ?

EDIT: In the end it does just works! I was missing the quotes around the variables.
« Last Edit: July 28, 2016, 03:29:46 pm by pasnox »