Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub Sort_List_m(ByRef lstFinalAddressDets   As List, ByVal recSvcDets As record, _
  2.         ByVal recOpportunity As Record)
  3.    
  4.     Dim brAddress               As New Bulkretrieve
  5.     Dim lstAddress              As New List
  6.     Dim nAddressDets            As Integer
  7.     Dim recAddressDets          As Record
  8.     Dim lstTempdAddrDets            As New list
  9.     Dim strDate             As String
  10.     Dim recAddressRole          As Record
  11.     Dim lstAddressRole          As New List
  12.     Dim lstCountry              As New List
  13.     Dim recCountry              As New Record
  14.     Dim recAddressView          As New Record
  15.    
  16.     '***********************************************************************
  17.     '* Set up procedure name for error logging
  18.     '***********************************************************************
  19.     strFunctionName_m = "Sort_List_m"
  20.  
  21.     On Error GoTo ERR_HANDLER
  22.     '************************************************************************
  23.     '* Retrieve existing addresses for this customer.
  24.     '************************************************************************
  25.     brAddress.SetRoot recSvcDets
  26.     brAddress.TraverseFromRoot 0, "x_address2svc_dets"
  27.     brAddress.TraverseFromParent 1, "x_addr_role2address", 0
  28.     brAddress.TraverseFromParent 2, "x_address2country", 1
  29.     brAddress.RetrieveRecords
  30.    
  31.     Set lstAddressRole = brAddress.GetRecordList(0)
  32.    
  33.     If(lstAddressRole.Count > 0) Then
  34.         '******************************************************************************
  35.         '* Loop thru existing records and strip date
  36.         '******************************************************************************
  37.         For nAddressDets = 0 To lstAddressRole.Count - 1
  38.        
  39.         'Joanne added code here SDI2669 - KYC
  40.         If strOppType = C_CCARD_OPP_G OR strOppType = C_PLOAN_OPP_G Then
  41.            
  42.             If (recAddressRole.GetField("x_role_name") = "Primary") Then
  43.             'get related address details from address role
  44.                 Set recAddressRole = lstAddressRole.ItemByIndex(nAddressDets)
  45.                 Set lstAddress = brAddress.GetRelatedRecordList _
  46.                             (recAddressRole, "x_addr_role2address")
  47.                    
  48.                 Set recAddressDets = lstAddress.ItemByIndex(0)
  49.             'get related country name from address details     
  50.                 Set lstCountry = brAddress.GetRelatedRecordList _
  51.                             (recAddressDets, "x_address2country")
  52.                     If (lstCountry.Count > 0) Then
  53.                         Set recCountry = lstCountry.ItemByIndex(0)
  54.                     Else
  55.                         Set recCountry.RecordType = "country"
  56.                     End If
  57.              If NOT ( Trim(recCountry.GetField("name")) = "United Kingdom" OR Trim(recCountry.GetField("name")) = "Ireland" ) Then
  58.                         Debug.print "JC in here -  can't progress"
  59.                         'lngWhichButton = App.MsgBox("Address must be UK or Ireland", cbOK, " ")
  60.                     Else
  61.                         Debug.print "JC - Good to go!"
  62.                 End If
  63.             Else
  64.                 Debug.print "Address role was secondary"
  65.             End If
  66.         End If
  67.         'Joanne Code end
  68.             Set recAddressRole = lstAddressRole.ItemByIndex(nAddressDets)
  69.             Set lstAddress = brAddress.GetRelatedRecordList _
  70.                         (recAddressRole, "x_addr_role2address")
  71.                
  72.             Set recAddressDets = lstAddress.ItemByIndex(0)
  73.                
  74.             Set lstCountry = brAddress.GetRelatedRecordList _
  75.                         (recAddressDets, "x_address2country")
  76.             If (lstCountry.Count > 0) Then
  77.                 Set recCountry = lstCountry.ItemByIndex(0)
  78.             Else
  79.                 Set recCountry.RecordType = "country"
  80.             End If
  81.            
  82.             '************************************************************************
  83.             '* Create view
  84.             '************************************************************************
  85.             recAddressView.CreateView x_address_dets_v, recAddressRole
  86.             recAddressView.CreateView x_address_dets_v, recAddressDets
  87.             recAddressView.CreateView x_address_dets_v, recCountry
  88.             recAddressView.CreateView x_address_dets_v, recOpportunity
  89.             recAddressView.CreateView x_address_dets_v, recSvcDets
  90.            
  91.             '************************************************************************
  92.             '* Sorting list - strip date and append to list
  93.             '************************************************************************
  94.             strDate = recAddressView.GetField(x_date)
  95.             If (strDate = "") Then
  96.                 strDate = CStr(App.CurrentDate)
  97.                 strDate = Mid(strDate, 1, 10)
  98.             End If
  99.             StripDate_G strDate
  100.             recAddressView.SetField x_date, strDate
  101.            
  102.             lstTempdAddrDets.AppendItem recAddressView
  103.         Next
  104.         lstTempdAddrDets.Sort x_date, 1
  105.  
  106.         '************************************************************************
  107.         '* Loop thru records and change date field back to date format
  108.         '************************************************************************          
  109.         For nAddressDets = 0 To lstTempdAddrDets.Count - 1
  110.             Set recAddressDets = lstTempdAddrDets.ItemByIndex(nAddressDets)
  111.             strDate = recAddressDets.GetField(x_date)
  112.             UnStripDate_G strDate
  113.             recAddressDets.SetField x_date, strDate
  114.                
  115.             lstFinalAddressDets.AppendItem recAddressDets
  116.             lstFinalAddressDets.AllowDuplicates = False
  117.         Next
  118.                        
  119.     End If
  120.    
  121.     brAddress.Clear
  122.     errExit:
  123.         'clean up before exit
  124.         brAddress.Clear
  125.        
  126.         EXIT SUB
  127.     ERR_HANDLER:
  128.         'log error to file, popup message and then clean-up and exit
  129.         call openErrorFile_g()
  130.         call logErr_g(CStr(Err.Number), CStr(err.Description), err.Source, erl, strFunctionName_m)
  131.         call closeErrorFile_g()
  132.         app.msgbox C_ERROR_MESSAGE_BOX_G
  133.         resume errExit
  134. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement