debtor.ReadRecordFromAlternateAccountNo()  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

debtor.ReadRecordFromAlternateAccountNo()

Postby neil.interactit » Mon Feb 23, 2015 3:04 pm

Hi there,

I have a requirement to create SOEs based on data coming in from a third party system. This external system tracks debtors with a different ID to their record in Jiwa, so the external ID has been entered in Jiwa as "Alternate Account No". The requirement is to be able to locate the correct debtor on their "Alternate Account No".

Is there an "Alternate Account No" search option - debtor.ReadRecordFromAlternateAccountNo() - or another approach that I can use to achieve this?

Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 223
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: debtor.ReadRecordFromAlternateAccountNo()  Topic is solved

Postby Scott.Pearce » Mon Feb 23, 2015 3:46 pm

There is currently no "ReadRecordFromAlternateAccountNo" method, but it's a good idea and I've logged it for you as bug (enhancement) #11524. In the meantime, you could do this:

Code: Select all
Public Function GetDebtorIDFromAlternateAccountNo(ByVal DebtorAlternateAccountNotoRead As String) As String
            Dim SQL As String = ""
            Dim SQLReader As SqlDataReader = Nothing
            Dim SQLParam As SqlParameter = Nothing

            Try
                With JiwaApplication.Manager.Instance.Database
                    SQL = "SELECT DB_Main.DebtorID " &
                             "FROM DB_Main " &
                             "WHERE DB_Main.AltAccountNo = @AlternateAccountNo "

                    Using SQLCmd As SqlCommand = New SqlCommand(SQL, .SQLConnection, .SQLTransaction)

                        SQLParam = New SqlParameter("@AlternateAccountNo", System.Data.SqlDbType.Char)
                        SQLParam.Value = DebtorAlternateAccountNotoRead
                        SQLCmd.Parameters.Add(SQLParam)

                        SQLReader = SQLCmd.ExecuteReader()

                        If SQLReader.Read = True Then
                            Return SQLReader("DebtorID")
                        Else
                            Throw New JiwaFinancials.Jiwa.JiwaApplication.Exceptions.RecordNotFoundException(String.Format("Debtor with Alternate Account No. of '{0}' not found.", DebtorAlternateAccountNotoRead))
                        End If
                    End Using
                End With
            Finally
                If Not SQLReader Is Nothing Then
                    SQLReader.Close()
                End If
            End Try
        End Function


The call:

Code: Select all
Dim debtorID as string = GetDebtorIDFromAlternateAccountNo("Fred")
If Not debtorID is Nothing Then
    debtor.Read(debtorID)
End If
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: debtor.ReadRecordFromAlternateAccountNo()

Postby Mike.Sheen » Mon Feb 23, 2015 4:33 pm

neil.interactit wrote:Hi there,

I have a requirement to create SOEs based on data coming in from a third party system. This external system tracks debtors with a different ID to their record in Jiwa, so the external ID has been entered in Jiwa as "Alternate Account No". The requirement is to be able to locate the correct debtor on their "Alternate Account No".

Is there an "Alternate Account No" search option - debtor.ReadRecordFromAlternateAccountNo() - or another approach that I can use to achieve this?

Cheers,
Neil.


If this is the debtor maintenance business logic, then you can also use the Find method of the business logic:

Code: Select all
Dim debtor As JiwaDebtors.Debtor = JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic(Of JiwaDebtors.Debtor)()
debtor.Find(JiwaApplication.IJiwaNavigable.ReadModes.Actual, "AltAccountNo", "ValueToFind", "")
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

Re: debtor.ReadRecordFromAlternateAccountNo()

Postby neil.interactit » Mon Feb 23, 2015 4:55 pm

Hi guys,

Many thanks!

I implemented Scott's approach before seeing Mike's alternative. All sweet ... just a minor typo (should be debtor.ReadRecord) to adjust.

Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 223
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: debtor.ReadRecordFromAlternateAccountNo()

Postby Scott.Pearce » Thu Feb 26, 2015 9:48 am

JiwaDebtor.Debtor is Read, JiwaApplication.Entities.Debtor.Debtor is ReadRecord.

In any case, Mike's strategy would be more efficient.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221


Return to Technical and or Programming

Who is online

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

cron