JiwaApplication.Report.Configuration.Report error  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

JiwaApplication.Report.Configuration.Report error

Postby perry » Wed Jun 26, 2019 2:41 pm

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()
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

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

Postby Mike.Sheen » Wed Jun 26, 2019 2:51 pm

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)()
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755


Return to Technical and or Programming

Who is online

Users browsing this forum: Google [Bot] and 5 guests

cron