Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Sort_List_m(ByRef lstFinalAddressDets As List, ByVal recSvcDets As record, _
- ByVal recOpportunity As Record)
- Dim brAddress As New Bulkretrieve
- Dim lstAddress As New List
- Dim nAddressDets As Integer
- Dim recAddressDets As Record
- Dim lstTempdAddrDets As New list
- Dim strDate As String
- Dim recAddressRole As Record
- Dim lstAddressRole As New List
- Dim lstCountry As New List
- Dim recCountry As New Record
- Dim recAddressView As New Record
- '***********************************************************************
- '* Set up procedure name for error logging
- '***********************************************************************
- strFunctionName_m = "Sort_List_m"
- On Error GoTo ERR_HANDLER
- '************************************************************************
- '* Retrieve existing addresses for this customer.
- '************************************************************************
- brAddress.SetRoot recSvcDets
- brAddress.TraverseFromRoot 0, "x_address2svc_dets"
- brAddress.TraverseFromParent 1, "x_addr_role2address", 0
- brAddress.TraverseFromParent 2, "x_address2country", 1
- brAddress.RetrieveRecords
- Set lstAddressRole = brAddress.GetRecordList(0)
- If(lstAddressRole.Count > 0) Then
- '******************************************************************************
- '* Loop thru existing records and strip date
- '******************************************************************************
- For nAddressDets = 0 To lstAddressRole.Count - 1
- 'Joanne added code here SDI2669 - KYC
- If strOppType = C_CCARD_OPP_G OR strOppType = C_PLOAN_OPP_G Then
- If (recAddressRole.GetField("x_role_name") = "Primary") Then
- 'get related address details from address role
- Set recAddressRole = lstAddressRole.ItemByIndex(nAddressDets)
- Set lstAddress = brAddress.GetRelatedRecordList _
- (recAddressRole, "x_addr_role2address")
- Set recAddressDets = lstAddress.ItemByIndex(0)
- 'get related country name from address details
- Set lstCountry = brAddress.GetRelatedRecordList _
- (recAddressDets, "x_address2country")
- If (lstCountry.Count > 0) Then
- Set recCountry = lstCountry.ItemByIndex(0)
- Else
- Set recCountry.RecordType = "country"
- End If
- If NOT ( Trim(recCountry.GetField("name")) = "United Kingdom" OR Trim(recCountry.GetField("name")) = "Ireland" ) Then
- Debug.print "JC in here - can't progress"
- 'lngWhichButton = App.MsgBox("Address must be UK or Ireland", cbOK, " ")
- Else
- Debug.print "JC - Good to go!"
- End If
- Else
- Debug.print "Address role was secondary"
- End If
- End If
- 'Joanne Code end
- Set recAddressRole = lstAddressRole.ItemByIndex(nAddressDets)
- Set lstAddress = brAddress.GetRelatedRecordList _
- (recAddressRole, "x_addr_role2address")
- Set recAddressDets = lstAddress.ItemByIndex(0)
- Set lstCountry = brAddress.GetRelatedRecordList _
- (recAddressDets, "x_address2country")
- If (lstCountry.Count > 0) Then
- Set recCountry = lstCountry.ItemByIndex(0)
- Else
- Set recCountry.RecordType = "country"
- End If
- '************************************************************************
- '* Create view
- '************************************************************************
- recAddressView.CreateView x_address_dets_v, recAddressRole
- recAddressView.CreateView x_address_dets_v, recAddressDets
- recAddressView.CreateView x_address_dets_v, recCountry
- recAddressView.CreateView x_address_dets_v, recOpportunity
- recAddressView.CreateView x_address_dets_v, recSvcDets
- '************************************************************************
- '* Sorting list - strip date and append to list
- '************************************************************************
- strDate = recAddressView.GetField(x_date)
- If (strDate = "") Then
- strDate = CStr(App.CurrentDate)
- strDate = Mid(strDate, 1, 10)
- End If
- StripDate_G strDate
- recAddressView.SetField x_date, strDate
- lstTempdAddrDets.AppendItem recAddressView
- Next
- lstTempdAddrDets.Sort x_date, 1
- '************************************************************************
- '* Loop thru records and change date field back to date format
- '************************************************************************
- For nAddressDets = 0 To lstTempdAddrDets.Count - 1
- Set recAddressDets = lstTempdAddrDets.ItemByIndex(nAddressDets)
- strDate = recAddressDets.GetField(x_date)
- UnStripDate_G strDate
- recAddressDets.SetField x_date, strDate
- lstFinalAddressDets.AppendItem recAddressDets
- lstFinalAddressDets.AllowDuplicates = False
- Next
- End If
- brAddress.Clear
- errExit:
- 'clean up before exit
- brAddress.Clear
- EXIT SUB
- ERR_HANDLER:
- 'log error to file, popup message and then clean-up and exit
- call openErrorFile_g()
- call logErr_g(CStr(Err.Number), CStr(err.Description), err.Source, erl, strFunctionName_m)
- call closeErrorFile_g()
- app.msgbox C_ERROR_MESSAGE_BOX_G
- resume errExit
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement