Page 1 of 1

JiwaApplication.Report.Configuration.Report error

PostPosted: Wed Jun 26, 2019 2:41 pm
by perry
Hi,

I had a piece of code which emails a custom report from schedule and it works in 7.0.x
After importing to v7.2, I get null object reference error on report.ReadRecordFromFileName(ReportName)
However, if I chose to ignore it, the rest of code seems working ok.

Code: Select all
 Dim JiwaReport As JiwaApplication.JiwaPrintReport.JiwaPrintReport
            JiwaReport = manager.BusinessLogicFactory.CreateBusinessLogic(Of JiwaApplication.JiwaPrintReport.JiwaPrintReport)(Nothing)

            'JiwaReport.Setup()
            Dim report As New JiwaApplication.Report.Configuration.Report()
            report.Manager = manager

            Try
                report.ReadRecordFromFileName(ReportName)
            Catch ex As Exception
                'null ref error in v7.2
            End Try

            JiwaReport.LoadReport(report)
            Dim savedrange As JiwaApplication.JiwaPrintReport.SavedReportRange = JiwaReport.SavedReportRangeCollection.GetItem("Description", SavedRangeName)
            If Not savedrange Is Nothing Then
                JiwaReport.ApplyXMLToRanges(savedrange.XML)
            Else
                Exit Sub
            End If

            For Each formula As JiwaApplication.JiwaPrintReport.JiwaPrintFormula In JiwaReport.JiwaPrintFormulaCollection
                If formula.Name.ToUpper.Equals("PASS_DEBTOR") Then
                    formula.Content = candidate.AccountNo
                    Exit For
                End If
            Next

            JiwaReport.UpdateReport()

Re: JiwaApplication.Report.Configuration.Report error  Topic is solved

PostPosted: Wed Jun 26, 2019 2:51 pm
by Mike.Sheen
It's because you're new-ing the JiwaApplication.Report.Configuration.Report() instead of using the CollectionItemFactory to create it.

Change:
Code: Select all
Dim report As New JiwaApplication.Report.Configuration.Report()
report.Manager = manager


to be simply:
Code: Select all
Dim report As JiwaApplication.Report.Configuration.Report = Manager.CollectionItemFactory.CreateCollectionItem(Of JiwaApplication.Report.Configuration.Report)()