1
votes

I have created a report that the only parameter is the CustomerID from the SOOrder table. The parameter of CustomerID works in the same way as the original customer history report except for it uses the SOOrder.CustomerID instead of ARPayment.CustomerID as the linking field. I have created this customization to add the linking to the report:

public override void Initialize()
{
    Base.report.AddMenuAction(NewCustHistory);
}

public PXAction<Customer> NewCustHistory;
[PXUIField(DisplayName = "New Customer History", MapEnableRights = PXCacheRights.Select)]
[PXButton(ImageKey = PX.Web.UI.Sprite.Main.Report)]
public virtual IEnumerable newCustHistory(PXAdapter adapter)
{

  Customer customer = Base.BAccountAccessor.Current;
    if (customer != null)
    {
    Dictionary<string, string> parameters = new Dictionary<string, string>();
    parameters["CustomerID"] = customer.AcctCD;
    throw new PXReportRequiredException(parameters, "IN642501", "New Customer History");
    }
 return adapter.Get();
}

It compiles fine it's just when I try to run the report after a customer is selected I get these two errors in the trace:

Object reference not set to an instance of an object. 

   at PX.Data.Reports.BqlSoapCommand.a(PXGraph A_0, StringBuilder A_1, List`1 A_2) 
   at PX.Data.Reports.BqlSoapCommand.Parse(PXGraph graph, List`1 pars, List`1 tables, List`1 fields, List`1 sortColumns, StringBuilder text, Selection selection) 
   at PX.Data.BqlCommand.a(PXGraph A_0, PXView A_1) 
   at PX.Data.BqlCommand.GetText(PXGraph graph, PXView view) 
   at PX.Data.PXDatabaseProviderBase.Select(PXGraph graph, BqlCommand command, Int64 topCount, PXView view, PXDataValue[] pars) 
   at PX.Data.PXDatabaseProvider.Select(PXGraph graph, BqlCommand command, Int64 topCount, PXDataValue[] pars) 
   at PX.Data.PXDatabase.Select(PXGraph graph, BqlCommand command, Int64 topCount, PXDataValue[] pars) 
   at PX.Data.Reports.SoapNavigator.b() 
   at PX.Data.Reports.SoapNavigator.c() 
   at PX.Data.Reports.SoapNavigator.Reset() 
   at PX.Reports.Data.ReportNode.ProcessItem() 
   at PX.Reports.Data.ItemNode.Process(Object dataItem) 
   at PX.Reports.Data.ItemNode.Process() 
   at PX.Reports.Data.ReportNode.Process() 
   at PX.Reports.Data.ReportProcessor.ProcessReport(Report definition) 
   at PX.Data.PXLongOperation.<>c__DisplayClass65_0`1.b__0() 
   at PX.Data.PXLongOperation.<>c__DisplayClass18_0.b__0() 

As well as this one:

Object reference not set to an instance of an object. 

   at PX.Common.Async.Process[Result](String uniqueKey, Method`1 method, Int64 waitTimeout) 
   at PX.Reports.Web.WebReport.Render(HttpResponse response, String format, Int32 pageNumber, Boolean refresh, Boolean isAttacment, String locale) 
   at PX.Reports.Web.PageOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) 
   at PX.Reports.Web.HttpHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context) 
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

Here is the XML for the report: Report XML

Update 1: I have updated to the code to replicate the answer that was provided below. The error still persists. My Acumatica version is 6.10.0755.

1
Have you tried to use the customer "CD" value vs the "ID" value? you might need to pass in the string CD displayed value vs the INT ID value. See if that helps. - Brendan
I have updated the code above to use the CurrentCustomer view instead of the BAccount view. I have tried both CustomerID as well as skipping the var ccust and going to the BAccountID and the AcctCD directly. All ways still produce the same errors. I'm not sure if the one is a timeout issue or not? - Dane
what version of Acumatica? Also, I assume the name for your report parameter is "CustomerID" with caps and all (might need to match exactly). You can see this in the report. - Brendan
If you look at the customer graph you can see them calling a report using AcctCD. Not sure why you are selecting sales order in your example. You already have the current customer. Also, you have an IN prefix report. I assume this is correct but just confirming. - Brendan

1 Answers

1
votes

Using the customer history report example found on the customer page you can see it uses AcctCD as the report parameter for customer id

public PXAction<Customer> customerHistory;
[PXUIField(DisplayName = AR.Messages.CustomerHistory, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton(ImageKey = PX.Web.UI.Sprite.Main.Report)]
public virtual IEnumerable CustomerHistory(PXAdapter adapter)
{
    Customer customer = this.BAccountAccessor.Current;
    if (customer != null && customer.BAccountID > 0L)
    {
        Dictionary<string, string> parameters = new Dictionary<string, string>();
        parameters["CustomerID"] = customer.AcctCD;
        throw new PXReportRequiredException(parameters, "AR652000", AR.Messages.CustomerHistory);
    }
    return adapter.Get();
}

Make sure in your example for your custom report the following are correct:

  • The report parameter name for customer id must match as it exists on the report. Make sure "CustomerID" is the correct value and not something like "Customer_ID
  • Confirm the report IN642501 can be accessed from the sitemap/url without error. If not accessible then your redirect to the report is not going to work.
  • Try using Base.BAccountAccessor.Current as your source for the Customer record as the example shows.