LimeReport Forum

General Category | Основное => Discussion | Обсуждение => Topic started by: darktorres on June 06, 2016, 06:35:24 AM

Title: Print if not empty?
Post by: darktorres on June 06, 2016, 06:35:24 AM
Hi, is there some way to only print text from datasource if it´s not empty?
Title: Re: Print if not empty?
Post by: Arin Alex on June 06, 2016, 08:30:16 PM
Hi, What do you mean only print text ?
Title: Re: Print if not empty?
Post by: darktorres 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}
Title: Re: Print if not empty?
Post by: Arin Alex on June 07, 2016, 01:31:19 AM
Code: [Select]
$S{if ($D{db.price}!="") $D{db.price} + " "+$D{db.discount}; else ""}
Title: Re: Print if not empty?
Post by: darktorres on June 07, 2016, 07:51:34 PM
Thanks!
Title: Re: Print if not empty?
Post by: pasnox 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
Title: Re: Print if not empty?
Post by: Subst on June 23, 2016, 08:33:33 AM
try to use external variables from your program. That determine need or needless printing
Title: Re: Print if not empty?
Post by: Arin Alex on June 29, 2016, 11:03:37 PM
I have added "Suppress absent fields and variables warning" parameter to report settings
Title: Re: Print if not empty?
Post by: pasnox 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.