Page 1 of 1

Null test in a rich text component

Posted: Wed Jul 20, 2022 2:59 pm
by Negaton
Hello,
My version is 2020.4.2.
I have a rich text with some calls to different fields.
One of these statement is :

Code: Select all

{(DateToStr(SaleDocumentLine.xx_Date_Livraison)==null) ? "" : "Livraison prévue le : " + Format("{0:dd/MM/yyyy}", SaleDocumentLine.xx_Date_Livraison)}
What I want to do is to display a text and then a caption if my "xx_Date_Livraison" field is not null.

However, when "xx_Date_Livraison" field is null, nothing is displayed in my rich text box : I mean all the other statements displayed in my rich text disapear, such as if my "== null" test above was not executed.

The field xx_Date_Livraison is a date time. In the above code, I try to convert the date in string and then test if "==null" could work. It doesn't work.
I have also tried "IIF" syntax.
I have also tried "==DBNull.Vale" instead of "==null" : it displays an error message "operator == can't be applied to type System.DateTime and System.DBNull"

Thank you for your help

Re: Null test in a rich text component

Posted: Fri Jul 22, 2022 1:21 pm
by Lech Kulikowski
Hello,

Please check the following expression:
{(SaleDocumentLine.xx_Date_Livraison==null) ? "" : "Livraison prévue le : " + Format("{0:dd/MM/yyyy}", SaleDocumentLine.xx_Date_Livraison)}

If the issue is still present, please send us a sample report with test data that reproduces the issue for analysis.

Thank you.

Re: Null test in a rich text component

Posted: Fri Jul 22, 2022 2:53 pm
by Negaton
Thank you for your help. Your suggestion does not solve the problem.
The report is a part of a big software, with an sql data base. Is there any way to give you something a little smaller thant all the data and software ?

In the same time I have tried another approach : I now have two components in the Body Column Band : the original Rich Text and a new text box containing only your above code.
It works for the data, but my new text box is wirtten in the same line than the following rich text box.
Original Rich text box and new text box are in a panel, without margin and with "anchor top" defined.
If this use of rich text and text box could work, it could be good enough.
Following is the render of the use of rich text box and text box
Thank you again for your help.
Image

Re: Null test in a rich text component

Posted: Fri Jul 22, 2022 3:06 pm
by Negaton
That's solved : I found the property that made the report not working (in french, it was "Agrandir à la hauteur" / "Growing to the max height or dsomething like that in english

Re: Null test in a rich text component

Posted: Mon Jul 25, 2022 11:37 am
by Lech Kulikowski
Hello,

Thank you for the information.