Skip to main content
Solved

Having an issue debugging a Print action


Forum|alt.badge.img

I am trying to upgrade a customer. I am getting an error in a few places, especially around printing reports. (From 2021 R2 to 2022 R2)

I’m not sure how to debug this. The error is not tripped by my debugger. I go into Sales Quotes and try to do a “Print Quote” when I do that I get an error. I have no idea what report is being called, so I don’t know how to look at that.

I tried to do an override of the PrintQuote function, so I could see what was going on inside of it but no dice. It wont permit an override. This is the source to it:

public IEnumerable PrintQuote(PXAdapter adapter)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            string actualReportID = DefaultReportID;
			PXReportRequiredException ex = null;

			foreach (CRQuote item in adapter.Get<CRQuote>())
            {
				Save.Press();

				parameters[nameof(CRQuote.OpportunityID)] = item.OpportunityID;
				parameters[nameof(CRQuote.QuoteNbr)] = item.QuoteNbr;
				ex = PXReportRequiredException.CombineReport(ex, actualReportID, parameters, OrganizationLocalizationHelper.GetCurrentLocalization(this));

				throw ex;
			}

            return adapter.Get();
        }

 

How do I even start to debug this???

 

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:
 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:
 

[NullReferenceException: Object reference not set to an instance of an object.]
   PX.Common.Async.Process(String uniqueKey, Method`1 method, Int64 waitTimeout) +393
   PX.Reports.Web.WebReport.Render(HttpResponse response, String format, Int32 pageNumber, Boolean refresh, Boolean isAttacment, String locale) +1701
   PX.Reports.Web.PageOperation.PerformOperation(NameValueCollection , HttpResponse ) +329
   PX.Reports.Web.HttpHandler.9cgu5fxgy74bxllgs2mkjjw8x7qpcy66   (HttpContext ) +211
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +872
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +94

Best answer by darylbowman

You’ll notice that the ‘actualReportID’ is assigned a variable value, which you can’t see in this definition. But if you search higher on that code page, you’ll find that ‘DefaultReportID’ is “CR604500”

 

I’m guessing either CR604500 was customized at some point or it changed significantly in the new version.

View original
Did this topic help you find an answer to your question?

4 replies

darylbowman
Captain II
Forum|alt.badge.img+13
  • 1712 replies
  • Answer
  • August 1, 2023

You’ll notice that the ‘actualReportID’ is assigned a variable value, which you can’t see in this definition. But if you search higher on that code page, you’ll find that ‘DefaultReportID’ is “CR604500”

 

I’m guessing either CR604500 was customized at some point or it changed significantly in the new version.


darylbowman
Captain II
Forum|alt.badge.img+13

The report ID is CR604500. I posted a more comprehensive explanation of how I found that, but it got caught by the spam filter and needs to be approved by the mods.

I’m guessing the report was either customized at some point or it changed significantly in the new version.


Forum|alt.badge.img
  • Author
  • Varsity I
  • 76 replies
  • August 1, 2023

Thank you so much! But, that is not able to be overridden, right? (Just for the record because I tried that and couldn’t)

 

Thanks again!


darylbowman
Captain II
Forum|alt.badge.img+13

You could override the action itself and implement exactly the same code, with the slight change of changing the reportID:

public delegate IEnumerable PrintQuoteDelegate(PXAdapter adapter);
[PXOverride]
public IEnumerable PrintQuote(PXAdapter adapter, PrintQuoteDelegate baseMethod)
{
	Dictionary<string, string> parameters = new Dictionary<string, string>();
	string actualReportID = "newReportID";
	PXReportRequiredException ex = null;

	foreach (CRQuote item in adapter.Get<CRQuote>())
	{
		Save.Press();

		parameters[nameof(CRQuote.OpportunityID)] = item.OpportunityID;
		parameters[nameof(CRQuote.QuoteNbr)] = item.QuoteNbr;
		ex = PXReportRequiredException.CombineReport(ex, actualReportID, parameters, OrganizationLocalizationHelper.GetCurrentLocalization(this));

		throw ex;
	}

	return adapter.Get();
    //baseMethod(adapter);
}

Usually, you’d want to call the base method at some point, but this way, the base code would never actually run.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings