Supress null date fields

Hi,

I am creating a report that prints the Workorder Item Scheduled User rows, when some of the rows have NULL Start and Stop dates.

However, they always print as 01/01/0001 12:00:00 AM.

I tried setting “Process Null Values” to Suppress, but still they show. I also tried adding a formatting rule, but I couldn’t figure out the proper condition expression.

Can you let me know how to suppress printing the start and stop dates if they are null?

Thanks

Good morning

I would assume probably an “if” statement would be used - something like:

if (label.text = “01/01/0001 12:00:00 AM”)

{

labelxx.visible = false;

}

  • Joyce

For example, in the sample Dispatching Report template, if I had a workorder item with three scheduled techs, and one of them had no Service Start Date/Time nor Stop Date/Time, the report would look like this for the Service Start Date/Time datafield:

But if I edited the BeforePrint script for that field with the following (as on my computer it displays as 1/1/0001 12:00:00 AM - whereas yours might be different):

if (xrTableCell16.Text == “1/1/0001 12:00:00 AM”)

{

xrTableCell16.Visible = false;

}

else

xrTableCell16.Visible = true;

Then when the Service Start Date/Time equals 1/1/0001 12:00:00 AM, then that field is not visible, otherwise it is:

Thank you, that works

UPDATE: I added .Text to the end of xrTableCell39 in line 474 to look like this: if (xrTableCell39.Text == “1/1/0001 12:00:00 AM”)
and now I don’t get the script error but it is not suppressing the field from displaying. I’m baffled on this!

I just tried this as well but I get a script error - Operator ‘==’ cannot be applied to operands of type ‘DevExpress.XtraReports.UI.XRTableCell’ and ‘string’ Line 474 Column 5

I have copy and pasted the exact code from below and changed the field name to match my script which looks like this:

473 private void xrTableCell39_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
474 if (xrTableCell39 == “1/1/0001 12:00:00 AM”)
475
476 {
477 xrTableCell39.Visible = false;
478 }
479 else
480 xrTableCell39.Visible = true;
481
482
483 }

Am I missing something here?

Hello

I just redid the steps as directed in the previous post and got the same message you did.

Took a look, and the example did not include referring to the .Text of the tablecell. Not sure why it worked before, but edit the BeforePrint for that specific tablecell so it looks similar to:

if (xrTableCell16.Text == “1/1/0001 12:00:00 AM”)
{
xrTableCell16.Visible = false;
}
else
xrTableCell16.Visible = true;

Note the .Text on the if (xrTableCell16.Text == statement

If you continue to experience an issue and have a question about your custom report template, do export to a file, zip and attach along with your details.

  • Joyce

Hi Joyce,

Thanks for replying so quickly!!! I tried the .Text prior to your reply and the script error went away but the fields still show up. I’m leaning towards the issue being something to do with my formatting of the string…maybe. I am attaching a copy of the report for you to try on your end. Thanks a bunch!

PS: While you have the report, can you also look at the xrTableCell69_BeforePrint and maybe guide me in the right direction why it doesn’t work… :slight_smile:

Hi

Thank you for including your report template.

Do note that xrTableCell39 in your report template has to do with your Labor records, NOT with your Scheduled Users records.
Be very aware of this - so when you are troubleshooting, you have confirmed there is no start or stop time in the Labor record

When I import, and open that report template up via a workorder that has a labor record with no start or stop date/time and a part record, the following is what I see:

xrTableCell39

xrTableCell39 correctly does NOT display because you do have a BeforePrint that makes the field invisible if the exact output is
I see no issue here.

If your Labor’s Start Date & Time field still does not go invisible, then possibly your computer’s date/time format does not exactly match what you told that script to match which was exactly 1/1/0001 12:00:00 AM. Recheck your own computer settings, see what the date/time actually shows as to confirm.

Quick way to do this is to drag over to your report template’s Labor Detail3 area the Service Start Date & Time and confirm that it definitely does show exactly 1/1/0001 12:00:00 AM when you preview.

xrTableCell40
I imported your report template
I ran a Preview in the report template designer, realized couldn’t see all of the Service Stop Date & Time, so I made it bigger so I could see what it actually was returning.
When I did so, I could see that this field actually returns 01 Jan, 001 (12:00am - 12:00am

As this field is NOT returning 1/1/0001 12:00:00 AM, then obviously the script to make it invisible if it matches 1/1/0001 12:00:00 AM won’t work.

If in the future a field or tablecell doesn’t work, first recommendation would be to compare its properties to another that is working.
In this case, xrTableCell39 is working so I compared it to xrTableCell40

I removed the FormatString that was set for (Data Bindings) -> Text -> FormatString {0: - h:mm tt)} that was set for this field. And Previewed, and now no longer shows if the data/time is exactly 1/1/0001 12:00:00 AM

  • Joyce

Thanks Joyce,

It WAS the format string that was NOT exactly as I was entering in the script, just as I suspected. It’s all working now like it should… except when I do an HTML preview of the workorder in the report designer, the client address fields do not display. Is this by design or is there a setting missing? All other fields in the report show up as they should…

Once again, thanks for the timely response and steering me in the right direction.

Steve

Hello Steve

I would recommend that if a label on a report template is not displaying as expected, to check what specific Properties for it are set and try differently, especially if not the default Property.
Do of course work with a copy of your report template, so that you can easily go back to the original if any further issues arise.

Or if you would like additional help with this report template, I would be happy to do so Please contact me directly via support@ayanova.com from your own email address so can send the URL to make the minimum fee payment and we can go from there

  • Joyce