Jump to content
man

Custom report giving error 'Object reference not set to an instance of an object'

Recommended Posts

When trying to run one of our custom reports, I get the following error:

image.png.cf1ac887ce7ce99f84b867ba301c9817.png

  • This happens for all users, whether the report is run by right-clicking in the Browse menu, or running directly through Report Center.
  • It works perfectly if I ScreenConnect into the Automate server itself, and run the report from there.
  • Preview in Report Designer works.
  • We do have other custom reports which run fine, and this is a pretty simple report. It doesn't even include any subreports.
  • I have tried saving the report as .repx file then re-opening and publishing as a new report, but same result. 
  • I am using a custom query for the report in case that could be relevant:
SELECT
  computers.clientid,
  extrafield.id as ExtraFieldID,
  extrafield.name as ExtraFieldName,
  extrafield.fill as ExtraFieldDesc,
  computers.LastUsername,
  computers.name as ComputerName,
  computers.computerid as ComputerID,
  v_xr_computers.LocationName,
  v_xr_computers.ComputerOS,
  v_xr_computers.ComputerDateOSStart,
  v_xr_computers.ComputerDateLastContact,
  extrafielddata.value as ExtraFieldValue
FROM
  extrafield
  JOIN extrafielddata ON extrafielddata.extrafieldid = extrafield.id
  JOIN computers ON computers.computerid = extrafielddata.id
  JOIN v_xr_computers ON v_xr_computers.computerid = computers.computerid
WHERE
  extrafield.name LIKE 'ATG.Onboarding%'

 

Share this post


Link to post
Share on other sites

This is a massive pain in the ass for me too, but it is fixable.

First you need to enable enhanced logging by setting a property in the dashboard of plugin_reportcenter_loglevel and giving it a value of 6

Check to make sure the property does not already exist, if it does set it to 6. A restart of the DBAgent service is needed for it to process this.

Open the report and generate the error. You will find a log locally at "C:\programdata\LabTech Client\Logs\20190524_LTcErrors.txt" which may or may not give a good indication as to what the problem is. 

Post the relevant bit here once you have it and I'll help you diagnose why.

Share this post


Link to post
Share on other sites

Sweet. Here is the output. Looks like it is something to do with the custom query:

****************************************************************************************************************
2019-05-28 18:11:00.077 -04:00 [Information] APPLICATION_NAME=LTClient APPLICATION_VERSION=v190.110 THREAD_ID=1
"APPLICATION_NAME="LTClient""
"APPLICATION_VERSION="190.110""
"UTC_TIMESTAMP="2019-05-28 22:11:00.077""
"SOURCE="Plugin""
"MESSAGE="An error occurred while trying to load the report's data source. Error: Object reference not set to an instance of an object.
Stacktrace: 
   at ReportCenterPlugin.EndUserDesigner.LTXtraReport.ConvertQueriesToData(DataSet& myDataSet)
""
****************************************************************************************************************
2019-05-28 18:11:00.080 -04:00 [Information] APPLICATION_NAME=LTClient APPLICATION_VERSION=v190.110 THREAD_ID=1
"APPLICATION_NAME="LTClient""
"APPLICATION_VERSION="190.110""
"UTC_TIMESTAMP="2019-05-28 22:11:00.080""
"SOURCE="Plugin""
"MESSAGE="There was an error while loading the report viewer control, report: CUSTOM - Onboarding Report report id:54
Object reference not set to an instance of an object.
Stacktrace: 
   at ReportCenterPlugin.EndUserDesigner.LTXtraReport.ConvertQueriesToData(DataSet& myDataSet)
   at ReportCenterPlugin.EndUserDesigner.LTXtraReport.UpdateDataSource()
   at ReportCenterPlugin.EndUserDesigner.LTXtraReport.LoadLayout(Stream stream)
   at ReportCenterPlugin.ReportViewerControl.DeserializeReportData(Byte[] reportData)
   at ReportCenterPlugin.ReportViewerControl.ReportViewerControl_Load(Object sender, EventArgs e)
""
****************************************************************************************************************

 

Share this post


Link to post
Share on other sites

Does that custom query actually work in sqlyog? I it appears to be returning null or error which is why you'd get that error... 

Share this post


Link to post
Share on other sites

How are you executing the query? The WHERE clause is looking for custom EDFs. It works without errors for me, but I should mention that I can only use sqlyog when ScreenConnecting directly to the server, since I have found it impossible to use remotely with our cloud-hosted Automate server. 

I'll try using a regular Data Source and see if that helps. 

Share this post


Link to post
Share on other sites

Translating the query into a regular data source is proving to be a pain. It doesn't return any info in the Preview, even without the WHERE statement.

image.thumb.png.de98f3b970cad9238d91dafab5619934.png

Share this post


Link to post
Share on other sites

Here is how I fixed it. I decided to go back to my Custom Query report and troubleshoot that. I found the report worked if I ran it globally, rather than on a single client or computer. Using the logging method pointed out by Gavsto, I found the seemingly problematic piece of the query that it was putting on the end of my custom query: 

AND (`Custom Query`.`COMPUTERID` = @p1)

If I tried to run the report on a client, then it would say ClientID instead. Apparently this is how it allows you to filter the report by client, location, computer etc. It works fine when it isn't a Custom Query. I think the problem might be that the `Custom Query` table isn't actually a real thing until after the report is generated, so it is looking for something that doesn't exist. I don't know. Maybe it's a bug. Still not sure why it works directly on the server. 

I worked around the issue by publishing the report as a subreport, which included adding the parameter for ClientID, then linking the subreport from a blank parent report. The parent report includes the Computers table (not a Custom Query), simply for the purpose of filtering by ClientID or ComputerID, and passing the ClientID parameter through to the subreport. Happy to provide more detail if anyone runs into this. 

  • Thanks 1

Share this post


Link to post
Share on other sites

Having a similar error, however with a built-in report (Antivirus Health). Deleting and re-publishing it from Template results in the same "Object reference" error.

Here's what I see in the LTcErrors log. Any assistance interpreting this would be appreciated!

****************************************************************************************************************
2019-12-04 09:05:47.848 -05:00 [Information] APPLICATION_NAME=LTClient APPLICATION_VERSION=v190.307 THREAD_ID=1
"APPLICATION_NAME="LTClient""
"APPLICATION_VERSION="190.307""
"UTC_TIMESTAMP="2019-12-04 14:05:47.848""
"SOURCE="Plugin""
"MESSAGE="An error occurred while trying to load the report's data source. Error: Object reference not set to an instance of an object.
Stacktrace:
   at ReportCenterPlugin.EndUserDesigner.LTXtraReport.ConvertQueriesToData(DataSet& myDataSet)
""
****************************************************************************************************************
2019-12-04 09:05:47.851 -05:00 [Information] APPLICATION_NAME=LTClient APPLICATION_VERSION=v190.307 THREAD_ID=1
"APPLICATION_NAME="LTClient""
"APPLICATION_VERSION="190.307""
"UTC_TIMESTAMP="2019-12-04 14:05:47.851""
"SOURCE="Plugin""
"MESSAGE="There was an error while loading the report viewer control, report: Antivirus Health report id:20
Object reference not set to an instance of an object.
Stacktrace:
   at ReportCenterPlugin.EndUserDesigner.LTXtraReport.ConvertQueriesToData(DataSet& myDataSet)
   at ReportCenterPlugin.EndUserDesigner.LTXtraReport.UpdateDataSource()
   at ReportCenterPlugin.EndUserDesigner.LTXtraReport.LoadLayout(Stream stream)
   at ReportCenterPlugin.ReportViewerControl.DeserializeReportData(Byte[] reportData)
   at ReportCenterPlugin.ReportViewerControl.ReportViewerControl_Load(Object sender, EventArgs e)
""
****************************************************************************************************************
2019-12-04 09:07:53.361 -05:00 [Information] APPLICATION_NAME=LTClient APPLICATION_VERSION=v190.307 THREAD_ID=1
"APPLICATION_NAME="LTClient""
"APPLICATION_VERSION="190.307""
"UTC_TIMESTAMP="2019-12-04 14:07:53.361""
"SOURCE="Control Center""
"MESSAGE="No context menu items loaded for child context menu item provider with Guid 8bbc939c-a64b-49d5-a443-f959472a8424""
****************************************************************************************************************

 

Share this post


Link to post
Share on other sites

Try this:

  • Re-publish it as a subreport
  • Create a blank report and add the Computers table to the Data Source
  • Add the subreport to that blank report

Share this post


Link to post
Share on other sites

I don't have the option to re-publish as a SubReport...presumably since this is a built-in report template (Antivirus Health).

image.png.fef1cef14302cd30b52619c04b667793.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...