Page 1 of 1
debtor.ReadRecordFromAlternateAccountNo()
Posted:
Mon Feb 23, 2015 3:04 pm
by neil.interactit
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.
Re: debtor.ReadRecordFromAlternateAccountNo()
Posted:
Mon Feb 23, 2015 3:46 pm
by Scott.Pearce
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
Re: debtor.ReadRecordFromAlternateAccountNo()
Posted:
Mon Feb 23, 2015 4:33 pm
by Mike.Sheen
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", "")
Re: debtor.ReadRecordFromAlternateAccountNo()
Posted:
Mon Feb 23, 2015 4:55 pm
by neil.interactit
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.
Re: debtor.ReadRecordFromAlternateAccountNo()
Posted:
Thu Feb 26, 2015 9:48 am
by Scott.Pearce
JiwaDebtor.Debtor is Read, JiwaApplication.Entities.Debtor.Debtor is ReadRecord.
In any case, Mike's strategy would be more efficient.