<?xml version="1.0" encoding="utf-8"?>
  <finScript version="1.00" exportedUtcDate="2024-09-17T23:48:32.0000000">
    <CreatedUserId>ADMIN</CreatedUserId>
    <CreatedUtcDate>2024-09-12T04:09:22.4610000</CreatedUtcDate>
    <UpdatedUserId>ADMIN</UpdatedUserId>
    <UpdatedUtcDate>2024-09-17T23:47:38.8050000</UpdatedUtcDate>
    <ScriptId>HWEAICE</ScriptId>
    <Description>Equifax (Australia) Individual Credit Enquiry</Description>
    <ScriptType>HtmlWidget</ScriptType>
    <Active>true</Active>
    <AllowUI>false</AllowUI>
    <Bookmarks />
    <Category />
    <Code>' HtmlWidget_EquifaxAU_Individual
Option Explicit On
Option Strict On

' ##################################################################
' Equifax (Australia) Individual Credit Enquiry wizard HTML Widget
' 
' (c) Copyright Intersoft Systems Limited 2020
' 
' Version: 1.14 (18/09/2024)
'
' Usage: System-supplied HTML Widget
' ##################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.00  31/01/2020  ISS      J023388   Created
'    1.06  09/02/2022  ISS      J028266   Support for Drivers Licence Card Number
'    1.07  12/07/2022  ISS      J028905   Show readonly cost centre information
'    1.08  22/07/2022  ISS      J026867   Implement supported products
'                               J029213   Limit products based on Cost Centre options
'          01/11/2022  ISS      J029792   'Green' Medicare cards now only allow Month &amp; Year expiry
'    1.09  08/12/2022  ISS      J030148   IDMatrix Previous Enquiry Support
'    1.10  16/03/2023  ISS      J030537   Default product update
'    1.11  25/05/2023  ISS      J031155   Default product not set
'    1.12  27/05/2024  ISS      J033579   Added Print button
'    1.13  02/08/2024  ISS      J033953   VedaScore Apply scorecard support
'    1.14  18/09/2024  ISS      J029950   Changed the Workflow Executor to the finBL.HtmlWidgetUtilities.WorkflowItemComplete function
' #################################################################

' Constants
Private Const FORM_KEY As String = "EquifaxAU_Individual"
Private Const SERVICE_ID As String = "VedaConnectAU"
Private Const SUPPORTED_PRODUCTS As String = "VedaScore Apply,IDMatrix,IDMatrix Previous Enquiry,ScoreSeeker"

' Common Parameters
Private mAccountAppId As String
Private mAccountAppApplicantPk As Integer
Private mBranchId As String
Private mClientId As String
Private mWorkflowPk As Integer
Private mWorkflowItemPk As Integer

' Objects
Private mCombinedParameters As ISKeyValueList
Private mParameters As ISKeyValueList
Private mStartupParameters As ISKeyValueList

Public Function Main(eventId As String,
                     parametersJson As String,
                     startUpParametersJson As String,
                     hostingContext As isefinHtmlWidgetHostingContext,
                     requestInfo As finScriptRequestInfo,
                     ByRef returnValue As String) As Boolean

  ' Assume Success
  Main = True

  ' Get Parameters
  mParameters = finBL.CreateKeyValueList()
  mParameters.FromSimpleJsonString(parametersJson)
  mStartupParameters = finBL.CreateKeyValueList()
  mStartupParameters.FromSimpleJsonString(startUpParametersJson)

  ' Get Combined Parameters (Startup Parameters updated with event Parameters)
  mCombinedParameters = mStartupParameters.Clone()
  mCombinedParameters.UpdateFromKeyValueList(mParameters, True)

  ' Get Common Parameters
  With mCombinedParameters
    mAccountAppId = .GetString("AccountAppId")
    mAccountAppApplicantPk = .GetInteger("AccountAppApplicantPk")
    mBranchId = .GetString("BranchId")
    mClientId = .GetString("ClientId")
    mWorkflowPk = .GetInteger("WorkflowPk")
    mWorkflowItemPk = .GetInteger("WorkflowItemPk")
  End With

  ' Handle Events
  Select Case eventId
    Case ""
      ' Main event, i.e., return initial HTML content (excluding html and body tags)
      returnValue = ScriptInfo.TemplateText

    Case "GetBranchDefaults"
      ' Get Branch Defaults
      Main = GetBranchDefaults(returnValue)

    Case "GetClientSummary"
      ' Get Client Summary
      Main = GetClientSummary(returnValue)

    Case "GetInitialisationInfo"
      ' Get Initialisation Information required for this wizard
      Main = GetInitialisationInfo(returnValue)

    Case "GetOptions"
      ' Get Options
      Main = GetOptions(parametersJson, returnValue)

    Case "GetServiceReport"
      ' Get Service Report
      Main = GetServiceReport(parametersJson, returnValue)

    Case "PerformEnquiry"
      ' Perform Enquiry
      Main = PerformEnquiry(parametersJson, returnValue)

    Case "WizardValidate"
      ' Validate wizard page
      Main = WizardValidate(parametersJson, returnValue)

    Case Else
      finBL.Error.ErrorBeginFormat("Unhandled event '{0}'.", eventId)
      Main = False
  End Select

End Function

''' &lt;summary&gt;
'''  Creates a Credit Enquiry Request for a Client.
''' &lt;/summary&gt;
Private Function CreateCreditEnquiryRequestForClient(branchId As String,
                                                     product As String,
                                                     ByRef creditEnquiryRequest As ISCreditEnquiryRequest) As Boolean

  Dim Client As finClient
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Get Client or Applicant objects
  Success = GetClientOrApplicant(Client, Nothing, Nothing)

  ' Create Request
  If Success Then
    creditEnquiryRequest = finBL.CreditBureau.CreateCreditEnquiryRequest(SERVICE_ID, iseProductClass.CreditEnquiry, product, branchId)
    If creditEnquiryRequest Is Nothing Then
      Success = False
      finBL.Error.ErrorBeginFormat("Unhandled Product '{0}'.", product)
    End If
  End If

  ' Update
  If Success Then
    If finBL.CreditBureau.UpdateCreditEnquiryRequestOptions(creditEnquiryRequest, Client) Then
      Success = finBL.CreditBureau.UpdateCreditEnquiryRequestFromClient(creditEnquiryRequest, Client, False)
    Else
      Success = False
    End If
  End If

  ' Update with specified Branch
  If Success Then
    If Len(branchId) &lt;&gt; 0 AndAlso finBL.Branches.Exists(branchId) Then
      creditEnquiryRequest.BranchPk = finBL.Branches(branchId).Pk
    Else
      creditEnquiryRequest.BranchPk = Client.BranchPk
    End If
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Create Context Data for Scripts.
''' &lt;/summary&gt;
Private Function CreateScriptContextData() As ISKeyValueList

  Return finBL.HtmlWidgetUtilities.CreateScriptContextData(ScriptInfo, FORM_KEY)

End Function

''' &lt;summary&gt;
'''  Get Branch Defaults.
''' &lt;/summary&gt;
Private Function GetBranchDefaults(ByRef returnValue As String) As Boolean

  Dim ApplyScorecards As String
  Dim Data As Object
  Dim DefaultApplyScorecards As String
  Dim DefaultProduct As String
  Dim DefaultScoreSeekerScorecards As String  
  Dim ProductsList As String
  Dim ScoreSeekerScorecards As String
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Get the Products
  Me.GetProductListAndDefault(ProductsList, DefaultProduct, ApplyScorecards, DefaultApplyScorecards, ScoreSeekerScorecards, DefaultScoreSeekerScorecards)

  ' Create Response
  Data = New With {
    .DefaultProduct = DefaultProduct,
    .ProductsList = ProductsList,
    .ApplyScorecards = ApplyScorecards,
    .ScoreSeekerScorecards = ScoreSeekerScorecards,
    .DefaultApplyScorecards = DefaultApplyScorecards,
    .DefaultScoreSeekerScorecards = DefaultScoreSeekerScorecards,
    .DisplayApplyScorecards = (Len(ApplyScorecards) &lt;&gt; 0),
    .DisplayScoreSeekerScorecards = (Len(ScoreSeekerScorecards) &lt;&gt; 0)    
  }

  ' Serialise
  Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(Data, returnValue)

  Return Success

End Function

''' &lt;summary&gt;
'''  Get a finClient and, optionally, a finAccountAppApplicant object from Web Service properties.
''' &lt;/summary&gt;
Private Function GetClientOrApplicant(ByRef client As finClient,
                                      ByRef accountApp As finAccountApp,
                                      ByRef accountAppApplicant As finAccountAppApplicant) As Boolean

  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise ByRef Parameters
  client = Nothing
  accountApp = Nothing
  accountAppApplicant = Nothing

  ' Initialise
  If Len(mClientId) = 0 Then
    ' Applicant
    accountApp = finBL.CreateAccountApp()
    If accountApp.Load(mAccountAppId) Then
      If accountApp.Applicants.ExistsPk(mAccountAppApplicantPk) Then
        accountAppApplicant = accountApp.Applicants.ItemByPk(mAccountAppApplicantPk)

        ' Create Client from Applicant
        Success = accountAppApplicant.CreateClient(True, client)
      Else
        Success = False
        finBL.Error.ErrorBegin("Applicant not found for this Account Application.")
      End If
    Else
      Success = False
    End If
  Else
    ' Client
    client = finBL.CreateClient()
    Success = client.Load(mClientId)
  End If

  ' Validate
  If Success Then
    If Not Client.IsIndividual AndAlso Len(Client.LastName) = 0 Then
      Success = False
      finBL.Error.ErrorBegin("Organisation type Clients must have a 'Person Acting' defined to perform an Individual Credit Enquiry.")
    End If
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Get Client Summary.
''' &lt;/summary&gt;
Private Function GetClientSummary(ByRef returnValue As String) As Boolean

  Dim BranchId As String
  Dim ContactEmail As String
  Dim ContactMobile As String
  Dim ContactPhone As String
  Dim ContactWorkPhone As String
  Dim CreditEnquiryRequest As ISCreditEnquiryRequest
  Dim DriverLicenceExpiry As Date
  Dim DriverLicenceCardNumber As String
  Dim DriverLicenceNumber As String
  Dim DriverLicenceState As String
  Dim Employer As String
  Dim Html As String
  Dim MedicareColour As String
  Dim MedicareExpiry As Date
  Dim MedicareMiddleNames As String
  Dim MedicareNumber As String
  Dim MedicareReference As Integer
  Dim PassportExpiry As Date
  Dim PassportIssuer As String
  Dim PassportNumber As String
  Dim Product As String
  Dim sb As finHtmlSummaryPage2StringBuilder
  Dim ShowContactDetails As Boolean
  Dim ShowDriversLicence As Boolean
  Dim ShowDriversLicenceCardNumber As Boolean
  Dim ShowEmployer As Boolean
  Dim ShowMedicare As Boolean
  Dim ShowPassport As Boolean
  Dim Success As Boolean
  Dim SummaryTable As ISSummaryTable

  ' Assume Success
  Success = True

  ' Get Parameters
  With mCombinedParameters
    BranchId = .GetString("BranchId")
    Product = .GetString("Product")
  End With

  ' Create Request
  If Success Then
    Success = CreateCreditEnquiryRequestForClient(BranchId, Product, CreditEnquiryRequest)
  End If

  ' Get Information from the Request
  If Success Then
    ' Get Product-specific Details
    Select Case CreditEnquiryRequest.GetType()
      Case GetType(ISCreditEnquiryRequest_VedaConnectAU_VedaScoreApplySubmitEnquiry)
        ' VedaScore Apply
        ShowDriversLicence = True
        ShowEmployer = True

        With DirectCast(CreditEnquiryRequest, ISCreditEnquiryRequest_VedaConnectAU_VedaScoreApplySubmitEnquiry)
          DriverLicenceNumber = .DriverLicenceNumber
          Employer = .Employer
        End With

      Case GetType(ISCreditEnquiryRequest_VedaConnectAU_IDMatrixSubmitEnquiry)
        ' IDMatrix
        ShowContactDetails = True
        ShowDriversLicence = True
        ShowDriversLicenceCardNumber = True
        ShowPassport = True
        ShowMedicare = True

        With DirectCast(CreditEnquiryRequest, ISCreditEnquiryRequest_VedaConnectAU_IDMatrixSubmitEnquiry)
          ContactPhone = .Phone.HomePhoneNumber.PhoneNumber
          ContactMobile = .Phone.MobilePhoneNumber.PhoneNumber
          ContactWorkPhone = .Phone.WorkPhoneNumber.PhoneNumber
          ContactEmail = .EmailAddress

          DriverLicenceNumber = .DriversLicenceDetails.Number
          DriverLicenceState = .DriversLicenceDetails.StateCode
          DriverLicenceExpiry = .DriversLicenceDetails.DateOfExpiry
          DriverLicenceCardNumber = .DriversLicenceDetails.CardNumber

          MedicareNumber = .Medicare.CardNumber
          MedicareReference = .Medicare.ReferenceNumber
          MedicareColour = .Medicare.CardColourDescription
          MedicareExpiry = .Medicare.DateOfExpiry
          MedicareMiddleNames = .Medicare.MiddleNameOnCard

          PassportNumber = .PassportDetails.Number
          PassportIssuer = .PassportDetails.CountryDescription
          PassportExpiry = .PassportDetails.DateOfExpiry
        End With

      Case GetType(ISCreditEnquiryRequest_VedaConnectAU_ScoreSeekerSubmitEnquiry)
        ' ScoreSeeker
        ShowDriversLicence = True
        ShowEmployer = True

        With DirectCast(CreditEnquiryRequest, ISCreditEnquiryRequest_VedaConnectAU_ScoreSeekerSubmitEnquiry)
          DriverLicenceNumber = .DriverLicenceNumber
          Employer = .Employer
        End With
    End Select
  End If

  ' Get Summary
  If Success Then
    ' Initialise
    sb = finBL.CreateHtmlSummaryPage2StringBuilder()
    SummaryTable = finBL.CreateSummaryTable()

    ' Create Summary
    With SummaryTable
      .TableClass = iseSummaryTableClass.Information

      .Columns.AddText(10).NoBreakChars = 20
      .Columns.AddText()

      .TextBefore = "{{info|If any of these details are incorrect or out-of-date, close this form, update the Client record and try again.}}"

      With .Rows
        ' Person's details
        .AddSectionHeading2("Person's details")
        .AddCaptionText("First Name:", CreditEnquiryRequest.FirstName)
        .AddCaptionText("Middle Names:", CreditEnquiryRequest.MiddleNames)
        .AddCaptionText("Last Name:", CreditEnquiryRequest.LastName)
        .AddCaptionDate("Date of Birth:", CreditEnquiryRequest.DateOfBirth)
        .AddCaptionText("Gender:", CreditEnquiryRequest.Gender)

        ' Contact Details
        If ShowContactDetails Then
          .AddSectionHeading2("Contact Details")
          .AddCaptionText("Phone No:", ContactPhone)
          .AddCaptionText("Mobile:", ContactMobile)
          .AddCaptionText("Work:", ContactWorkPhone)
          .AddCaptionText("Email:", ContactEmail)
        End If

        ' Drivers Licence
        If ShowDriversLicence Then
          .AddSectionHeading2("Drivers Licence")
          If Len(DriverLicenceNumber) = 0 Then
            .AddWiki("{{warning|Australian Drivers Licence details not found.}}")
          Else
            If Len(DriverLicenceState) &lt;&gt; 0 Then .AddCaptionText("State:", DriverLicenceState)
            .AddCaptionText("Licence No:", DriverLicenceNumber)
            If DriverLicenceExpiry &lt;&gt; Nothing Then .AddCaptionDate("Expiry:", DriverLicenceExpiry)
            If ShowDriversLicenceCardNumber Then
              ' Card Number
              If Len(DriverLicenceCardNumber) = 0 Then
                .AddCaptionWiki("Card No:", "{{warning|Card Number not specified.}}")
              Else
                .AddCaptionText("Card No:", DriverLicenceCardNumber)
              End If
            End If
          End If
        End If

        ' Passport
        If ShowPassport Then
          .AddSectionHeading2("Passport")
          If Len(PassportNumber) = 0 Then
            .AddWiki("{{warning|Passport details not found.}}")
          Else
            If Len(PassportIssuer) &lt;&gt; 0 Then .AddCaptionText("Issuer:", PassportIssuer)
            .AddCaptionText("Passport No:", PassportNumber)
            If PassportExpiry &lt;&gt; Nothing Then .AddCaptionDate("Expiry:", PassportExpiry)
          End If
        End If

        ' Medicare
        If ShowMedicare Then
          .AddSectionHeading2("Medicare")
          If Len(MedicareNumber) = 0 Then
            .AddWiki("{{warning|Medicare details not found.}}")
          Else
            .AddCaptionText("Medicare No:", MedicareNumber)
            .AddCaptionInteger("Individual Ref:", MedicareReference)
            .AddCaptionText("Colour:", MedicareColour)
                        
            If UCase(MedicareColour) = "GREEN" AndAlso MedicareExpiry &lt;&gt; Nothing Then
              .AddCaptionText("Expiry:", Format(MedicareExpiry, "MM/yyyy"))
            Else 
              .AddCaptionDate("Expiry:", MedicareExpiry)
            End If            
            .AddCaptionText("Middle Names:", MedicareMiddleNames)
          End If
        End If

        ' Employment Details
        If ShowEmployer Then
          .AddSectionHeading2("Employment Details")
          If Len(Employer) = 0 Then
            .AddWiki("{{warning|Employment details not found.}}")
          Else
            .AddCaptionText("Employer:", Employer)
          End If
        End If

        ' Address details
        .AddSectionHeading2("Address details")
        .AddCaptionAddressDetailsPhysical("Current:", CreditEnquiryRequest.ToAddressDetails(False))
        .AddCaptionAddressDetailsPhysical("Previous:", CreditEnquiryRequest.ToAddressDetails(True))
      End With
    End With

    ' Finalise
    With sb
      .Initialise(iseSummaryPageTarget.WebInternal)
      .HtmlHeaderBegin("", isefinSummaryPageStyle.Blocks)
      .HtmlHeaderEnd()

      .SectionColumnsBegin()
      .ColumnBegin("100%")
      .BlockBegin("Client Summary",,,False)
      .SummaryTableAppend(SummaryTable)
      .BlockEnd()
      .ColumnEnd()
      .SectionColumnsEnd()

      .HtmlFinalise()

      Html = .ToString(True)
    End With
  End If

  ' Finalise
  If Success Then
    returnValue = Html
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Get Initialisation Information required for this wizard.
''' &lt;/summary&gt;
Public Function GetInitialisationInfo(ByRef response As String) As Boolean

  Dim AccountApp As finAccountApp
  Dim AccountAppApplicant As finAccountAppApplicant
  Dim BranchRO As finBranchRO
  Dim Client As finClient
  Dim DefaultProduct As String
  Dim FormInitialisationInfo As FormInitialisationInfo
  Dim ProductsList As String
  Dim strTemp As String
  Dim Success As Boolean
  Dim ScoreSeekerScorecards As String
  Dim ApplyScorecards As String
  Dim DefaultApplyScorecards As String
  Dim DefaultScoreSeekerScorecards As String  
  
  ' Assume Success
  Success = True

  ' Validate
  If Len(mClientId) = 0 AndAlso mAccountAppApplicantPk = 0 Then
    Success = False
    finBL.Error.ErrorBegin("Client Id or Account Application Applicant details not specified.")
  ElseIf Len(mClientId) = 0 AndAlso mAccountAppApplicantPk &lt;&gt; 0 AndAlso Len(mAccountAppId) = 0 Then
    Success = False
    finBL.Error.ErrorBegin("Account Application must also be specified.")
  ElseIf Len(mClientId) &lt;&gt; 0 AndAlso finBL.CurrentUserInformation.IsClientFilteredOut(mClientId) Then
    Success = False
    finBL.Error.ErrorBegin("You do not have permission to view this Client.")
  ElseIf Len(mAccountAppId) &lt;&gt; 0 AndAlso finBL.CurrentUserInformation.IsAccountAppFilteredOut(mAccountAppId) Then
    Success = False
    finBL.Error.ErrorBegin("You do not have permission to view this Account Application.")
  ElseIf finBL.Database.IsReadOnly Then
    Success = False
    finBL.Error.ErrorBegin("Access denied. Database is Read-Only.")
  ElseIf mWorkflowPk = 0 AndAlso mWorkflowItemPk &lt;&gt; 0 Then
    Success = False
    finBL.Error.ErrorBegin("You must also specify the WorkflowPk if a Workflow Item has been specified.")
  ElseIf mWorkflowPk &lt;&gt; 0 AndAlso mWorkflowItemPk = 0 Then
    Success = False
    finBL.Error.ErrorBegin("You must also specify the WorkflowItemPk of the Workflow Item to Action if a Workflow has been specified.")
  End If

  ' Get Client or Applicant objects
  If Success Then
    Success = GetClientOrApplicant(Client, AccountApp, AccountAppApplicant)
  End If

  ' Get the Products
  Me.GetProductListAndDefault(ProductsList, DefaultProduct, ApplyScorecards, DefaultApplyScorecards, ScoreSeekerScorecards, DefaultScoreSeekerScorecards)
  
  ' Get Initialisation Info
  If Success Then
    FormInitialisationInfo = New FormInitialisationInfo()

    ' Other Properties
    With FormInitialisationInfo
      ' General
      If Client IsNot Nothing Then
        .ClientId = Client.ClientId
        .ClientName = Client.Name
      End If
      If AccountApp IsNot Nothing Then
        .AccountAppId = AccountApp.AccountAppId
        .AccountAppName = AccountApp.Name
        .AccountAppApplicantPk = AccountAppApplicant.Pk
        .AccountAppApplicantName = AccountAppApplicant.Name
      End If
      .WorkflowPk = mWorkflowPk

      ' Branch
      .BranchId = mBranchId
      If Len(.BranchId) = 0 AndAlso AccountApp IsNot Nothing Then .BranchId = AccountApp.BranchId
      If Len(.BranchId) = 0 AndAlso Client IsNot Nothing Then .BranchId = Client.BranchId

      ' Lists
      For Each BranchRO In finBL.Branches
        .Branches.Add(New BranchInfo(BranchRO, SERVICE_ID))
      Next
      .ProductsList = ProductsList

      ' Defaults
      .DefaultProduct = DefaultProduct
      
      ' Client Summary
      mCombinedParameters.SetString("Product", .DefaultProduct)
      mCombinedParameters.SetString("BranchId", .BranchId)
      If GetClientSummary(strTemp) Then
        .ClientSummary = strTemp
      End If

      ' Configuration
      .ServiceName = finBL.CreditBureau.GetServiceName(SERVICE_ID)
      .AllowBranch = Len(mBranchId) &lt;&gt; 0
      .ShowBranch = finBL.Settings.AddOns.CostCentre
      .TestMode = finBL.SettingsUser.CostCentreTestModeResolved
    End With
  End If

  ' Response
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(FormInitialisationInfo, response)
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Get Options.
''' &lt;/summary&gt;
Private Function GetOptions(parametersJson As String,
                            ByRef returnValue As String) As Boolean
  
  Dim AccountTypesCommercial As String
  Dim AccountTypesConsumer As String
  Dim AllowDriversLicenceCheck As Boolean
  Dim AllowMedicareCheck As Boolean
  Dim AllowPassportCheck As Boolean
  Dim AllowVisaCheck As Boolean
  Dim ApplyScorecards As String
  Dim BranchId As String
  Dim BureauReference As String
  Dim Client As finClient
  Dim CostCentreResolved_EquifaxAU As finCostCentreResolved_EquifaxAU
  Dim CreditEnquiryRequest As ISCreditEnquiryRequest
  Dim Data As Object
  Dim DefaultApplyScorecards As String
  Dim DefaultPermissionType As String
  Dim DefaultProduct As String
  Dim DefaultRelationship As String
  Dim DefaultScoreSeekerScorecards As String
  Dim ListReadOnly As ISListReadOnly
  Dim Permissions As String
  Dim Product As String
  Dim ProductsList As String
  Dim Relationships As String
  Dim ScoreSeekerScorecards As String
  Dim Success As Boolean
  
  ' Assume Success
  Success = True

  ' Get Parameters
  With mCombinedParameters
    BranchId = .GetString("BranchId")
    Product = .GetString("Product")
  End With

  ' Get Cost Centre Defaults for Equifax
  CostCentreResolved_EquifaxAU = finBL.CostCentresResolved.ItemByBranchId(BranchId).EquifaxAU

  ' Get Client
  Success = GetClientOrApplicant(Client, Nothing, Nothing)

  ' Create Request for this Product
  If Success Then
    CreditEnquiryRequest = finBL.CreditBureau.CreateCreditEnquiryRequest(SERVICE_ID, iseProductClass.CreditEnquiry, Product, BranchId)

    If CreditEnquiryRequest Is Nothing Then
      Success = False
      finBL.Error.ErrorBegin("Cannot create Credit Enquiry Request.")
    Else
      If finBL.CreditBureau.UpdateCreditEnquiryRequestOptions(CreditEnquiryRequest, Client) Then
        Success = finBL.CreditBureau.UpdateCreditEnquiryRequestFromClient(CreditEnquiryRequest, Client)
      Else
        Success = False
      End If
    End If
  End If

  ' Retrieve the scorecards
  If Success Then
    Me.GetProductListAndDefault(ProductsList, DefaultProduct, ApplyScorecards, DefaultApplyScorecards, ScoreSeekerScorecards, DefaultScoreSeekerScorecards)
  End If
  
  If Success Then
    ' Ensure Branch is what has been specified, not default from the Client
    If finBL.Branches.Exists(BranchId) Then
      CreditEnquiryRequest.BranchPk = finBL.Branches(BranchId).Pk
    Else
      CreditEnquiryRequest.BranchPk = 0
    End If

    ' Get Options page information
    Select Case CreditEnquiryRequest.GetType()
      Case GetType(ISCreditEnquiryRequest_VedaConnectAU_VedaScoreApplySubmitEnquiry)
        ' Vedascore Apply
        Dim Request As ISCreditEnquiryRequest_VedaConnectAU_VedaScoreApplySubmitEnquiry
        
        Request = DirectCast(CreditEnquiryRequest, ISCreditEnquiryRequest_VedaConnectAU_VedaScoreApplySubmitEnquiry)
        With Request
          AccountTypesConsumer = .AccountTypes.GetDescriptionsList().ToCsvString()
          AccountTypesCommercial = .CommercialAccountTypes.GetDescriptionsList().ToCsvString()
          Permissions = .PermissionTypes.GetDescriptionsList().ToCsvString()
          DefaultPermissionType = CostCentreResolved_EquifaxAU.CreditEnquiryDefaultApplyPermissionTypeResolved
          DefaultApplyScorecards = CostCentreResolved_EquifaxAU.CreditEnquiryDefaultApplyScoreCardList
          BureauReference = .BureauReference

          ' Relationships
          ListReadOnly = .Relationships.GetDescriptionsList()
          If ListReadOnly.Count &lt;&gt; 0 Then
            DefaultRelationship = ListReadOnly(0)
          End If
          Relationships = ListReadOnly.ToCsvString()
        End With

        ' Set Scorecards
        ScoreSeekerScorecards = ""
        
      Case GetType(ISCreditEnquiryRequest_VedaConnectAU_IDMatrixSubmitEnquiry)
        ' ID Matrix
        AllowDriversLicenceCheck = CostCentreResolved_EquifaxAU.CreditEnquiryIdMatrixAllowDriversCheck
        AllowMedicareCheck = CostCentreResolved_EquifaxAU.CreditEnquiryIdMatrixAllowMedicareCheck
        AllowPassportCheck = CostCentreResolved_EquifaxAU.CreditEnquiryIdMatrixAllowPassportCheck
        AllowVisaCheck = CostCentreResolved_EquifaxAU.CreditEnquiryIdMatrixAllowVisaCheck

        ' Set Scorecards
        ApplyScorecards = ""
        ScoreSeekerScorecards = ""
        
      Case GetType(ISCreditEnquiryRequest_VedaConnectAU_IDMatrixPreviousEnquiry)
        ' ID Matrix Previous Enquiry

        ' Set Scorecards
        ApplyScorecards = ""
        ScoreSeekerScorecards = ""

      Case GetType(ISCreditEnquiryRequest_VedaConnectAU_ScoreSeekerSubmitEnquiry)
        ' ScoreSeeker
        Dim Request As ISCreditEnquiryRequest_VedaConnectAU_ScoreSeekerSubmitEnquiry
        
        Request = DirectCast(CreditEnquiryRequest, ISCreditEnquiryRequest_VedaConnectAU_ScoreSeekerSubmitEnquiry)
        With Request
          AccountTypesConsumer = .AccountTypes.GetDescriptionsList().ToCsvString()
          AccountTypesCommercial = .CommercialAccountTypes.GetDescriptionsList().ToCsvString()
          Permissions = .PermissionTypes.GetDescriptionsList().ToCsvString()
          DefaultPermissionType = CostCentreResolved_EquifaxAU.CreditEnquiryDefaultScoreSeekerPermissionTypeResolved
          DefaultScoreSeekerScorecards = CostCentreResolved_EquifaxAU.CreditEnquiryDefaultScoreSeekerScoreCardList

          ' Relationships
          ListReadOnly = .Relationships.GetDescriptionsList()
          If ListReadOnly.Count &lt;&gt; 0 Then
            DefaultRelationship = ListReadOnly(0)
          End If
          Relationships = ListReadOnly.ToCsvString()
        End With

        ' Set Scorecards
        ApplyScorecards = ""
        
      Case Else
        Success = False
        finBL.Error.ErrorBeginFormat("Unhandled Product '{0}'.", Product)
    End Select
  End If

  ' Build Object
  If Success Then
    Data = New With {
      .AccountTypesConsumer = AccountTypesConsumer,
      .AccountTypesCommercial = AccountTypesCommercial,
      .Relationships = Relationships,
      .Permissions = Permissions,
      .DefaultPermission = DefaultPermissionType,
      .DefaultRelationship = DefaultRelationship,
      .DefaultApplyScorecards = DefaultApplyScorecards,
      .DefaultScoreSeekerScorecards = DefaultScoreSeekerScorecards,
      .AllowDriversLicenceCheck = AllowDriversLicenceCheck,
      .AllowMedicareCheck = AllowMedicareCheck,
      .AllowPassportCheck = AllowPassportCheck,
      .AllowVisaCheck = AllowVisaCheck,
      .BureauReference = BureauReference,
      .ApplyScorecards = ApplyScorecards,
      .ScoreSeekerScorecards = ScoreSeekerScorecards,
      .DisplayApplyScorecards = Len(ApplyScorecards) &lt;&gt; 0,
      .DisplayScoreSeekerScorecards = Len(ScoreSeekerScorecards) &lt;&gt; 0
      }
  End If

  ' Finalise
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(Data, returnValue)
  End If

  Return Success

End Function

Private Sub GetProductListAndDefault(ByRef productsCsv As String,
                                     ByRef defaultProduct As String,
                                     ByRef applyScorecards As String,
                                     ByRef defaultApplyScorecards As String,
                                     ByRef ScoreSeekerScorecards As String,
                                     ByRef defaultScoreSeekerScorecards As String)

  Dim BranchId As String
  Dim CostCentreResolved_EquifaxAU As finCostCentreResolved_EquifaxAU
  Dim SupportedProducts As ISList
  
  ' Initialise ByRef
  productsCsv = ""
  defaultProduct = ""
  applyScorecards = ""
  ScoreSeekerScorecards = ""
  defaultApplyScorecards = ""
  defaultScoreSeekerScorecards = ""
  
  ' Parameters
  With mCombinedParameters
    BranchId = .GetString("BranchId")
  End With

  ' Get Cost Centre
  CostCentreResolved_EquifaxAU = finBL.CostCentresResolved.ItemByBranchId(BranchId).EquifaxAU

  ' Get Default Product
  defaultProduct = CostCentreResolved_EquifaxAU.CreditEnquiryDefaultProductIndividual

  ' Product List - could change depending on Cost Centre
  SupportedProducts = finBL.Runtime.CreateList()
  SupportedProducts.AppendCsvString(SUPPORTED_PRODUCTS)
  If Not CostCentreResolved_EquifaxAU.CreditEnquiryScoreSeekerUseProduct Then
    SupportedProducts.Remove("ScoreSeeker", True)
  End If
  If Not CostCentreResolved_EquifaxAU.CreditEnquiryIdMatrixUseProduct Then
    SupportedProducts.Remove("IDMatrix", True)
    SupportedProducts.Remove("IDMatrix Previous Enquiry", True)
  End If

  If SupportedProducts.Count = 1 Then
    defaultProduct = SupportedProducts(0)
  Else
    ' Fix default product based on Cost Centre
    Select UCase(DefaultProduct)
      Case "IDMATRIX", "IDMATRIX PREVIOUS ENQUIRY"
        If Not CostCentreResolved_EquifaxAU.CreditEnquiryIdMatrixUseProduct Then
          defaultProduct = "VedaScore Apply"
        End If
      Case "SCORESEEKER"
        If Not CostCentreResolved_EquifaxAU.CreditEnquiryScoreSeekerUseProduct Then
          defaultProduct = "VedaScore Apply"
        End If
    End Select
  End If

  ' Override if the Default Product is blank
  If Len(DefaultProduct) = 0 Then
    defaultProduct = finBL.CreditBureau.GetServiceDefaultEnquiryProduct(SERVICE_ID, iseProductTarget.Individual, BranchId)
  End If

  ' Check Default Product is supported
  If SupportedProducts.Count = 0 Then
    defaultProduct = ""
  ElseIf Not SupportedProducts.Exists(defaultProduct, True) Then
    defaultProduct = SupportedProducts(0)
  End If
  
  productsCsv = SupportedProducts.ToCsvString()

  ' Scorecards
  If Len(CostCentreResolved_EquifaxAU.CreditEnquiryApplyScoreCardListId) &lt;&gt; 0 AndAlso finBL.InformationLists.Exists(CostCentreResolved_EquifaxAU.CreditEnquiryApplyScoreCardListId) Then
    With finBL.InformationLists(CostCentreResolved_EquifaxAU.CreditEnquiryApplyScoreCardListId)
      applyScorecards = .List
    End With
  End If  
  defaultApplyScorecards = CostCentreResolved_EquifaxAU.CreditEnquiryDefaultApplyScoreCardList
  
  If finBL.InformationLists.Exists("EquifaxAUScoreSeeker") Then
    With finBL.InformationLists("EquifaxAUScoreSeeker")
      ScoreSeekerScorecards = .List
    End With
  End If 
  defaultScoreSeekerScorecards = CostCentreResolved_EquifaxAU.CreditEnquiryDefaultScoreSeekerScoreCardList
  
End Sub

''' &lt;summary&gt;
'''  Get Service Report.
''' &lt;/summary&gt;
Private Function GetServiceReport(parametersJson As String,
                                  ByRef returnValue As String) As Boolean

  Dim Html As String
  Dim ServiceLogPk As Integer
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Get Parameters
  With mCombinedParameters
    ServiceLogPk = .GetInteger("ServiceLogPk")
  End With

  ' Get Report
  Html = GetServiceReportInternal(ServiceLogPk)

  ' Finalise
  If Success Then
    returnValue = Html
  End If

  Return Success

End Function

Private Function GetServiceReportInternal(serviceLogPk As Integer) As String

  Dim Html As String
  Dim ServiceLog As ISServiceLog

  ' Get HTML
  If finBL.Database.GetServiceLog(serviceLogPk, ServiceLog) Then
    If Not finBL.CreditBureau.GetCreditEnquiryHtmlFromServiceLog(ServiceLog, Html, ScriptInfo.Target) Then
      Html = finBL.GetHtmlErrorMessage(finBL.Error.Message, finBL.Error.Details)
    End If
  Else
    Html = finBL.GetHtmlErrorMessage(finBL.Error.Message, finBL.Error.Details)
  End If

  Return Html

End Function

''' &lt;summary&gt;
'''  Perform Enquiry.
''' &lt;/summary&gt;
Private Function PerformEnquiry(parametersJson As String,
                                ByRef returnValue As String) As Boolean

  Dim AccountAppLogPk As Integer
  Dim ClientLogPk As Integer
  Dim CreditEnquiryRequest As ISCreditEnquiryRequest
  Dim CreditEnquiryResponse As ISCreditEnquiryResponse
  Dim ExecutePostFailed As Boolean
  Dim Html As String
  Dim List As ISList
  Dim obj As Object
  Dim ServiceLogCreateDetails As ISServiceLogCreateDetails
  Dim ServiceLogPk As Integer
  Dim strTemp As String
  Dim Success As Boolean
  Dim Warnings As ISValidationItems
  Dim WizardFinishParameters As WizardFinishParameters

  ' Assume Success
  Success = True
  
  ' Initialise
  Warnings = finBL.Runtime.CreateValidationItems()

  ' Parse Parameters
  If finBL.Runtime.WebUtilities.DeserialiseJsonStringToObject(parametersJson, GetType(WizardFinishParameters), obj) Then
    WizardFinishParameters = DirectCast(obj, WizardFinishParameters)
  Else
    Success = False
  End If

  ' Create Enquiry
  If Success Then
    Success = CreateCreditEnquiryRequestForClient(WizardFinishParameters.BranchId, WizardFinishParameters.Product, CreditEnquiryRequest)
  End If

  ' Options
  If Success Then
    Select Case CreditEnquiryRequest.GetType()
      Case GetType(ISCreditEnquiryRequest_VedaConnectAU_VedaScoreApplySubmitEnquiry)
        ' VedaScore Apply
        Dim Request As ISCreditEnquiryRequest_VedaConnectAU_VedaScoreApplySubmitEnquiry

        Request = DirectCast(CreditEnquiryRequest, ISCreditEnquiryRequest_VedaConnectAU_VedaScoreApplySubmitEnquiry)
        With Request
          ' NOTE: Permission needs to be done before Account Type
          .PermissionTypeDescription = WizardFinishParameters.Permission
          .AccountTypeDescription = WizardFinishParameters.AccountType
          .RelationshipDescription = WizardFinishParameters.Relationship
          .EnquiryAmount = WizardFinishParameters.AmountSought
          .IsCreditReview = WizardFinishParameters.CreditReviewEnquiry

          ' Scorecards
          List = finBL.Runtime.CreateList()
          List.FromCsvString(WizardFinishParameters.ScoreCards)
          .ScoreCards.FromList(List)
          
          If WizardFinishParameters.UseReference Then
            .BureauReference = WizardFinishParameters.CreditBureauReference
          Else
            .BureauReference = ""
          End If

          .AsyncRequest = WizardFinishParameters.AsynchronousEnquiry
        End With

      Case GetType(ISCreditEnquiryRequest_VedaConnectAU_IDMatrixSubmitEnquiry)
        ' IDMatrix
        Dim Request As ISCreditEnquiryRequest_VedaConnectAU_IDMatrixSubmitEnquiry

        Request = DirectCast(CreditEnquiryRequest, ISCreditEnquiryRequest_VedaConnectAU_IDMatrixSubmitEnquiry)
        With Request
          .ConsentGiven = WizardFinishParameters.HasConsent
          .PerformDriversLicence = WizardFinishParameters.IncludeDriversLicence
          .PerformMedicare = WizardFinishParameters.IncludeMedicare
          .PerformPassport = WizardFinishParameters.IncludePassport
          .PerformPassportVisa = WizardFinishParameters.IncludeVisa
        End With

      Case GetType(ISCreditEnquiryRequest_VedaConnectAU_IDMatrixPreviousEnquiry)
        ' IDMatrix Previous Enquiry
        Dim Request As ISCreditEnquiryRequest_VedaConnectAU_IDMatrixPreviousEnquiry

        Request = DirectCast(CreditEnquiryRequest, ISCreditEnquiryRequest_VedaConnectAU_IDMatrixPreviousEnquiry)
        With Request
          .EnquiryId = WizardFinishParameters.EnquiryId
        End With
        
      Case GetType(ISCreditEnquiryRequest_VedaConnectAU_ScoreSeekerSubmitEnquiry)
        ' ScoreSeeker
        Dim Request As ISCreditEnquiryRequest_VedaConnectAU_ScoreSeekerSubmitEnquiry

        Request = DirectCast(CreditEnquiryRequest, ISCreditEnquiryRequest_VedaConnectAU_ScoreSeekerSubmitEnquiry)
        With Request
          ' NOTE: Permission needs to be done before Account Type
          .PermissionTypeDescription = WizardFinishParameters.Permission
          .AccountTypeDescription = WizardFinishParameters.AccountType
          .RelationshipDescription = WizardFinishParameters.Relationship
          .EnquiryAmount = WizardFinishParameters.AmountSought
          .IsCreditReview = WizardFinishParameters.CreditReviewEnquiry

          ' Scorecards
          List = finBL.Runtime.CreateList()
          List.FromCsvString(WizardFinishParameters.ScoreCards)
          .ScoreCards.FromList(List)

          ' Access Seeker
          If WizardFinishParameters.AccessSeeker Then
            .FileAccessClientReference = WizardFinishParameters.FileAccessRef
          Else
            .FileAccessClientReference = ""
          End If

          .AsyncRequest = WizardFinishParameters.AsynchronousEnquiry
        End With

      Case Else
        finBL.Error.ErrorBeginFormat("Unhandled Product '{0}'.", WizardFinishParameters.Product)
        Success = False
    End Select
  End If

  ' Execute
  If Success Then
    If finBL.CreditBureau.ExecuteCreditEnquiry(CreditEnquiryRequest, CreditEnquiryResponse, ServiceLogCreateDetails, True, mWorkflowPk, mWorkflowItemPk, ExecutePostFailed, ClientLogPk, AccountAppLogPk) Then
      ServiceLogPk = ServiceLogCreateDetails.ServiceLogPk
      If ExecutePostFailed Then Warnings.Add(finBL.Error.Message())
    Else
      Success = False
    End If
  End If

  ' Get Report
  If Success Then
    Html = GetServiceReportInternal(ServiceLogPk)
  End If

  ' Complete Workflow Item
  If Success Then
    finBL.HtmlWidgetUtilities.WorkflowItemComplete(mStartupParameters, strTemp)
    
    If Len(strTemp) &lt;&gt; 0 Then
      Warnings.Add("The Enquiry completed successfully, however the Workflow Item could not be actioned due to the following error:" &amp; vbNewLine &amp; vbNewLine &amp; strTemp)
    End If
  End If
    
  ' Finalise   
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(New WizardFinishDetails(AccountAppLogPk, ClientLogPk, Html, ServiceLogPk, Warnings.GetSummaryNumbered(False, False, True, , True, True)), returnValue)    
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Validate a Wizard page.
''' &lt;/summary&gt;
Private Function WizardValidate(parametersJson As String,
                                ByRef returnValue As String) As Boolean

  Dim BranchId As String
  Dim ConfirmList As New List(Of String)
  Dim Data As Object
  Dim FailedControlId As String
  Dim FailedMessage As String
  Dim PageId As String
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Get Parameters
  ' NOTE: Use the module mCombinedParameters since this contains Startup and event Parameters in a single Key/Value List
  With mCombinedParameters
    BranchId = .GetString("BranchId")
    PageId = .GetString("PageId")
  End With

  ' Validate Page
  Select Case PageId
    Case "General"
      ' Is Service Available
      If Not finBL.CreditBureau.IsServiceAvailable(iseProductClass.CreditEnquiry, SERVICE_ID, BranchId) Then
        FailedControlId = "cboBranch"
        FailedMessage = String.Format("This Service is not available or configured for Branch '{0}'.", BranchId)
      End If
  End Select

  ' Finalise
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(New WizardValidateResponse(Data, FailedMessage, FailedControlId), returnValue)
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Branch Information.
''' &lt;/summary&gt;
Public Class BranchInfo

  Public BranchId As String
  Public CostCentreText As String

  Public Sub New(branchRO As finBranchRO,
                 serviceId As String)

    Dim CostCentrePk As Integer

    Me.BranchId = branchRO.BranchId

    If finBLShared.Settings.AddOns.CostCentre Then
      If finBLShared.CostCentreFunctions.GetCostCentreFromBranchAndService(branchRO.Pk, serviceId, CostCentrePk) Then
        If finBLShared.CostCentres.ExistsPk(CostCentrePk) Then
          With finBLShared.CostCentres.ItemByPk(CostCentrePk)
            Me.CostCentreText = String.Format("This will be charged to Cost Centre &lt;b&gt;{0}&lt;/b&gt;, '{1}'.", .CostCentreId, finBLShared.HtmlEncode(.Description))
          End With
        End If
      End If
    End If

  End Sub

End Class



''' &lt;summary&gt;
'''  Wizard Initialisation Information.
''' &lt;/summary&gt;
Public Class FormInitialisationInfo

  ' Record
  Public AccountAppId As String
  Public AccountAppName As String
  Public AccountAppApplicantPk As Integer
  Public AccountAppApplicantName As String
  Public BranchId As String
  Public ClientId As String
  Public ClientName As String
  Public WorkflowPk As Integer

  ' Client Summary
  Public ClientSummary As String

  ' Lists
  Public Branches As New List(Of BranchInfo)
  Public ProductsList As String

  ' Defaults
  Public DefaultProduct As String
  Public DefaultApplyScorecards As String
  Public DefaultScoreSeekerScorecards As String

  ' Configuration
  Public ServiceName As String
  Public AllowBranch As Boolean
  Public ShowBranch As Boolean
  Public TestMode As Boolean

End Class



''' &lt;summary&gt;
'''  Finish details.
''' &lt;/summary&gt;
Public Class WizardFinishDetails

  ' General
  Public AccountAppLogPk As Integer
  Public ClientLogPk As Integer
  Public Html As String
  Public ServiceLogPk As Integer
  Public Warning As String

  Public Sub New(accountAppLogPk As Integer,
                 clientLogPk As Integer,
                 html As String,
                 serviceLogPk As Integer,
                 warning As String)

    Me.AccountAppLogPk = accountAppLogPk
    Me.ClientLogPk = clientLogPk
    Me.Html = html
    Me.ServiceLogPk = serviceLogPk
    Me.Warning = warning

  End Sub

End Class



''' &lt;summary&gt;
'''  Finish Parameters.
''' &lt;/summary&gt;
Public Class WizardFinishParameters

  Public AccessSeeker As Boolean
  Public AccountType As String
  Public AmountSought As Decimal
  Public AsynchronousEnquiry As Boolean
  Public BranchId As String
  Public CreditBureauReference As String
  Public CreditReviewEnquiry As Boolean
  Public EnquiryId As String
  Public FileAccessRef As String
  Public HasConsent As Boolean
  Public IncludeDriversLicence As Boolean
  Public IncludeMedicare As Boolean
  Public IncludePassport As Boolean
  Public IncludeVisa As Boolean
  Public Permission As String
  Public Product As String
  Public Relationship As String
  Public ScoreCards As String
  Public UseReference As Boolean

End Class



''' &lt;summary&gt;
'''  Validation details.
''' &lt;/summary&gt;
Public Class WizardValidateResponse

  Public Data As Object
  Public FailedMessage As String
  Public FailedControlId As String

  Public Sub New(data As Object,
                 failedMessage As String,
                 failedControlId As String)

    Me.Data = data
    Me.FailedMessage = failedMessage
    Me.FailedControlId = failedControlId

  End Sub

End Class</Code>
    <Language>VisualBasic</Language>
    <Notes>System defined HTML Widget.

Used as a finPOWER Connect Cloud compatible wizard to allow a "Equifax (Australia)" Individual Credit enquiry to be performed.

The following products are supported:
* VedaScore Apply
* IDMatrix
* IDMatrix Previous Enquiry
* ScoreSeeker</Notes>
    <PermissionKeyExecute />
    <ReferenceLinq>false</ReferenceLinq>
    <RunWithoutPrompts>false</RunWithoutPrompts>
    <TemplateText>&lt;div id="frmMain" class="is-widget-content" style="visibility: hidden;"&gt;

  &lt;!-- Form Header --&gt;
  &lt;header&gt;
    &lt;div class="header"&gt;&lt;/div&gt;
    &lt;div class="summary"&gt;&lt;/div&gt;
    &lt;!-- Tabs --&gt;
    &lt;div id="tabWizard" class="is-tabs"&gt;
      &lt;ul&gt;
        &lt;li tabId="General" tooltipText="Confirm who this enquiry is being made upon."&gt;Individual Credit Enquiry&lt;/li&gt;
        &lt;li tabId="Options" tooltipText=""&gt;Options&lt;/li&gt;
        &lt;li tabId="Enquiry" tooltipText="Credit Enquiry results."&gt;Credit Enquiry Report&lt;/li&gt;
      &lt;ul&gt;
    &lt;/div&gt;
  &lt;/header&gt;

  &lt;!-- Pages --&gt;
  &lt;div class="is-widget-form-body"&gt;
    &lt;!-- General --&gt;
    &lt;div id="pageGeneral"&gt;
      &lt;table class="is-form" style="height:100%"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:6em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblRecord"&gt;Client&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboRecord"&gt;Client:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboRecord" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr style="display:none"&gt;
          &lt;th&gt;&lt;label for="cboApplicant"&gt;Applicant:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboApplicant" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblBranch"&gt;Select the Branch to allocate costs to&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboBranch"&gt;Branch:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboBranch" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;/th&gt;
          &lt;td colspan="2"&gt;&lt;div id="divCostCentreInformation" class="is-info-text info small" style="display:none"&gt;&lt;/div&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblProduct"&gt;Select the Credit Bureau Product&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboProduct"&gt;Product:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboProduct" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr style="height:100%"&gt;
          &lt;td colspan="2" style="height:100%"&gt;&lt;div id="wbClientSummary" class="is-dock-fill"&gt;&lt;/div&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- Options --&gt;
    &lt;div id="pageOptions"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:10em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblEnquiryDetails"&gt;Enquiry details&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtEnquiryId"&gt;Enquiry Id:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtEnquiryId" /&gt;&lt;/td&gt;
        &lt;/tr&gt;        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkHasConsent" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboAccountType"&gt;Account Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboAccountType" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboRelationship"&gt;Relationship:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboRelationship" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="numAmountSought"&gt;Amount:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="numAmountSought" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblEnquiryOptions"&gt;Enquiry Options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboPermissionType"&gt;Permission Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboPermissionType" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkCreditReviewEnquiry" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="chklstApplyScorecards"&gt;Score Cards:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="chklstApplyScorecards" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="chklstScoreSeekerScorecards"&gt;Score Cards:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="chklstScoreSeekerScorecards" /&gt;&lt;/td&gt;
        &lt;/tr&gt;        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkAccessSeeker" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtFileAccessRef"&gt;File Access Ref:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtFileAccessRef" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkIncludeDriversLicence" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkIncludeMedicare" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkIncludePassport" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkIncludeVisa" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblDetails"&gt;Do you want to enquire using Client details or a Credit Bureau Reference?&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkUseReference" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboCreditBureauReference"&gt;Reference:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboCreditBureauReference" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;&lt;th colspan="2"&gt;&lt;label id="lblTestOptions"&gt;Test Options&lt;/label&gt;&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkAsynchronousEnquiry" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- Enquiry --&gt;
    &lt;div id="pageEnquiry"&gt;
      &lt;div id="wbSummary" class="is-dock-fill"&gt;&lt;/div&gt;
    &lt;/div&gt;

  &lt;/div&gt;

  &lt;!-- Form Footer --&gt;
  &lt;footer&gt;
    &lt;button id="cmdCancel" class="is-button"&gt;Cancel&lt;/button&gt;
    &lt;button id="cmdBack" class="is-button"&gt;&amp;lt; Back&lt;/button&gt;
    &lt;button id="cmdNext" class="is-button"&gt;Next &amp;gt;&lt;/button&gt;
    &lt;button id="cmdFinish" class="is-button ok"&gt;Finish&lt;/button&gt;
  &lt;/footer&gt;
&lt;/div&gt;

&lt;script&gt;
// Properties
var mRecord;
var mRecord_BranchDefaults;
var mRecord_Options;
var mEnquiryDetails;

// Controls
var C = {
  // General
  lblRecord: null,
  cboRecord: null,
  cboApplicant: null,
  lblBranch: null,
  cboBranch: null,
  divCostCentreInformation: null,
  lblProduct: null,
  cboProduct: null,
  wbClientSummary: null,

  // Options
  lblEnquiryDetails: null,
  txtEnquiryId: null,
  chkHasConsent: null,
  cboAccountType: null,
  cboRelationship: null,
  numAmountSought: null,

  lblEnquiryOptions: null,
  cboPermissionType: null,
  chkCreditReviewEnquiry: null,
  chklstApplyScorecards: null,
  chklstScoreSeekerScorecards: null,
  chkAccessSeeker: null,
  txtFileAccessRef: null,
  chkIncludeDriversLicence: null,
  chkIncludeMedicare: null,
  chkIncludePassport: null,
  chkIncludeVisa: null,

  lblDetails: null,
  chkUseReference: null,
  cboCreditBureauReference: null,
  lblTestOptions: null,
  chkAsynchronousEnquiry: null,

  // Enquiry
  wbSummary: null
}

// Form
var frmMain;
var tabWizard;

// Wizard Buttons
var cmdCancel;
var cmdBack;
var cmdNext;
var cmdFinish;

// Other
var mLastProduct = "";
var mLastFinishParametersJson = "";

// ==========
// Initialise
// ==========
$(function () {
  // Mobile optimisations
  $(window).resize(Form_Resize);

  // --------
  // Controls
  // --------
  //   General
  C.lblRecord = widget.UI.Label("lblRecord", {});
  C.cboRecord = widget.UI.DBCombo("cboRecord", {
    autoReadOnly: false,
    readOnly: true,
    showDropdown: false,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });
  C.cboApplicant = widget.UI.DBCombo("cboApplicant", {
    autoReadOnly: false,
    readOnly: true,
    showDropdown: false,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });

  C.lblBranch = widget.UI.Label("lblBranch", {});
  C.cboBranch = widget.UI.DBCombo("cboBranch", {
    width: widget.UI.FIELD_WIDTH_CODE_10,

    onChange: cboBranch_Change
  });
  C.divCostCentreInformation = $("#divCostCentreInformation");

  C.lblProduct = widget.UI.Label("lblProduct", {});
  C.cboProduct = widget.UI.ComboBox("cboProduct", {
    allowBlank: false,
    limitToList: true,
    maxLength: 50,
    onChange: cboProduct_Change,
  });

  C.wbClientSummary = widget.UI.PreviewPane("wbClientSummary", {});

  //   Options
  C.lblEnquiryDetails = widget.UI.Label("lblEnquiryDetails", {});
  C.txtEnquiryId = widget.UI.TextBox("txtEnquiryId", {
    allowBlank: false,
    maxLength: 30,
  });  
  C.chkHasConsent = widget.UI.CheckBox("chkHasConsent", {
    caption: "Has consent been obtained from the subject of the Enquiry?",
  });
  C.cboAccountType = widget.UI.ComboBox("cboAccountType", {
    allowBlank: false,
    maxLength: 30,
    limitToList: true,
  });
  C.cboRelationship = widget.UI.ComboBox("cboRelationship", {
    allowBlank: false,
    maxLength: 30,
    limitToList: true,
  });
  C.numAmountSought = widget.UI.NumberBox("numAmountSought", {
    decimals: -1,
    minValue: 0,
    maxValue: 9999999,
  });

  C.lblEnquiryOptions = widget.UI.Label("lblEnquiryOptions", {});
  C.cboPermissionType = widget.UI.ComboBox("cboPermissionType", {
    allowBlank: false,
    maxLength: 30,
    limitToList: true,
    onChange: cboPermissionType_Change,
  });
  C.chkCreditReviewEnquiry = widget.UI.CheckBox("chkCreditReviewEnquiry", {
    caption: "Is the Enquiry for a Credit Review?",
  });
  C.chklstApplyScorecards = widget.UI.CheckList("chklstApplyScorecards", {
    allowBlank: false,
  }); 
  C.chklstScoreSeekerScorecards = widget.UI.CheckList("chklstScoreSeekerScorecards", {
    allowBlank: false,
  });

  C.chkAccessSeeker = widget.UI.CheckBox("chkAccessSeeker", {
    caption: "ScoreSeeker Access Seeker Behavioral scores?",
    onChange: chkAccessSeeker_Change,
  });
  C.txtFileAccessRef = widget.UI.TextBox("txtFileAccessRef", {
    maxLength: 30,
  });
  C.chkIncludeDriversLicence = widget.UI.CheckBox("chkIncludeDriversLicence", {
    caption: "Include Driver's Licence check?",
  });
  C.chkIncludeMedicare = widget.UI.CheckBox("chkIncludeMedicare", {
    caption: "Include Medicare check?",
  });
  C.chkIncludePassport = widget.UI.CheckBox("chkIncludePassport", {
    caption: "Include Australian Passport check?",
    onChange: chkIncludePassport_Change,
  });
  C.chkIncludeVisa = widget.UI.CheckBox("chkIncludeVisa", {
    caption: "Include Visa check?",
    onChange: chkIncludeVisa_Change,
  });

  C.lblDetails = widget.UI.Label("lblDetails", {});
  C.chkUseReference = widget.UI.CheckBox("chkUseReference", {
    caption: "Enquire by Veda Bureau Reference?",
    onChange: chkUseReference_Change,
  });
  C.cboCreditBureauReference = widget.UI.ComboBox("cboCreditBureauReference", {
    allowBlank: false,
    maxLength: 30,
  });
  C.lblTestOptions = widget.UI.Label("lblTestOptions", {});
  C.chkAsynchronousEnquiry = widget.UI.CheckBox("chkAsynchronousEnquiry", {
    caption: "Asynchronous Enquiry?",
  });

  //   Enquiry
  C.wbSummary = widget.UI.PreviewPane("wbSummary", {
    showPrint: true,
  });

  // Grids

  // Create Widget form
  // NOTE: Hide by default for a cleaner startup
  frmMain = new widget.UI.Form("frmMain", { visible: false });

  // Create Tabs
  tabWizard = new widget.UI.Tabs("tabWizard", { style: "wizard" });

  // Handle Wizard Buttons
  cmdCancel = $("#cmdCancel");
  cmdBack = $("#cmdBack");
  cmdNext = $("#cmdNext");
  cmdFinish = $("#cmdFinish");
  cmdCancel.click(tabWizard_Cancel);
  cmdBack.click(function() { tabWizard_Move(-1); });
  cmdNext.click(function() { tabWizard_Move(1); });
  cmdFinish.click(function() { Form_ExecuteAction("Finish"); });

  // Handle Notifications
  widget.ActionNotificationHandle(Widget_NotificationHandler);

  // Reset
  Form_Reset();
});

// ==========
// Reset Form
// ==========
function Form_Reset() {
  // Defaults

  // Set Tab
  tabWizard.SelectedTabId("General");

  // Resize
  Form_Resize();

  // Load Record (i.e., initialise wizard)
  Record_Load();
}

// ===========
// Load Record
// ===========
function Record_Load() {
  // Initialise
  mRecord = null;
  mRecord_BranchDefaults = null;
  mRecord_Options = null;

  // Hide content
  frmMain.Visible(false);

  // Block UI
  widget.UI.Block("Initialising, please wait...");

  // Load Initialisation details
  widget.GetString("GetInitialisationInfo", {},
    // Success
    function (data) {
      mRecord = JSON.parse(data);

      // Give Collections ability to lookup by code
      widget.ArrayAllowLookupById(mRecord.Branches, "BranchId");

      // Load Fields
      Fields_Load();
    },

    // Fail
    function (message) {
      widget.UI.MsgBoxAlert("fail: " + message);
      Fields_Load();
    }
  );
}

// ===========
// Load Fields
// ===========
function Fields_Load() {
  if (mRecord) {
    // General
    if (mRecord.AccountAppId) {
      // Applicant
      C.lblRecord.Text("Account Application");
      C.cboRecord.Caption("Application:");
      C.cboRecord.RefreshUnbound(mRecord.AccountAppId, mRecord.AccountAppName);
      C.cboApplicant.RefreshUnbound(mRecord.AccountAppApplicantPk, mRecord.AccountAppApplicantName);
    }
    else {
      // Client
      C.lblRecord.Text("Client");
      C.cboRecord.Caption("Client:");
      C.cboRecord.RefreshUnbound(mRecord.ClientId, mRecord.ClientName);
    }
    C.cboBranch.Text(mRecord.BranchId);
    C.cboProduct.Text(mRecord.DefaultProduct);

    C.wbClientSummary.SetContent(mRecord.ClientSummary, false);
  }

  // Unblock UI
  widget.UI.Unblock();

  // Update Controls

  // Update fields
  Fields_Update();

  // Refresh Tab
  tabWizard_Refresh();
}

// =============
// Update Fields
// =============
function Fields_Update() {
  // Heading
  if (mRecord &amp;&amp; mRecord.TestMode) {
    widget.SetHeading(mRecord.ServiceName + " Individual Credit Enquiry (Test Mode)");
  }

  // Information Lists

  // Lists
  if (mRecord) {
    C.cboProduct.ListFromCsvString(mRecord.ProductsList);
    if (mRecord.ShowBranch) {
      C.cboBranch.RefreshFromStandardRange("Branches");
    }
  }

  // Controls
  if (mRecord) {
    C.cboApplicant.VisibleRow(mRecord.AccountAppApplicantPk != 0);

    C.lblBranch.ReadOnly(mRecord.AllowBranch);
    C.cboBranch.ReadOnly(mRecord.AllowBranch);
    C.lblBranch.VisibleRow(mRecord.ShowBranch);
    C.cboBranch.VisibleRow(mRecord.ShowBranch);
    
    if(!mRecord.TestMode) {
      C.lblTestOptions.VisibleRow(false);
      C.chkAsynchronousEnquiry.VisibleRow(false);
    }

    cboBranch_Change();
  }

  // Update Buttons
  tabWizard_UpdateButtons();

  // Show content
  frmMain.Visible(mRecord != null);

  // Resize Tab
  tabWizard_Resize();
}

// =========
// cboBranch
// =========
function cboBranch_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  widget.GetString("GetBranchDefaults", { branchId: C.cboBranch.Text() },
    // Success
    function(data) {
      mRecord_BranchDefaults = JSON.parse(data);

      if(mRecord_BranchDefaults) {
        C.cboProduct.ListFromCsvString(mRecord_BranchDefaults.ProductsList);
        C.cboProduct.Text(mRecord_BranchDefaults.DefaultProduct);
        C.chklstApplyScorecards.ListFromCsvString(mRecord_BranchDefaults.ApplyScorecards);        
        C.chklstApplyScorecards.Text(mRecord_BranchDefaults.DefaultApplyScorecards);
        C.chklstScoreSeekerScorecards.ListFromCsvString(mRecord_BranchDefaults.ScoreSeekerScorecards);
        C.chklstScoreSeekerScorecards.Text(mRecord_BranchDefaults.DefaultScoreSeekerScorecards);        
      }
    },

    // Failure
    function(errorMessage) {
      widget.UI.Unblock();
      widget.UI.MsgBoxAlert(errorMessage);
    }
  );

  // Cost Centre
  // Hide by default
  C.divCostCentreInformation.hide();

  // Get Cost Centre message
  if (mRecord.ShowBranch &amp;&amp; C.cboBranch.Text()) {
    var branch = mRecord.Branches.GetItem(C.cboBranch.Text());

    if (branch) {
      var message = branch.CostCentreText;
    }
  }

  // Show / Hide message
  if (message) {
    C.divCostCentreInformation.html(message);
    C.divCostCentreInformation.show();
  }
}

// =================
// cboPermissionType
// =================
function cboPermissionType_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  // Credit Review Enquiry Checkbox
  switch(C.cboPermissionType.Text().toUpperCase()) {
    case "COMMERCIAL+CONSUMER":
      C.chkCreditReviewEnquiry.ReadOnly(false);
      break;

    default:
      C.chkCreditReviewEnquiry.ReadOnly(true);
      break;
  }

  // Account Types
  if(mRecord_Options) {
    switch(C.cboPermissionType.Text().toUpperCase()) {
      case "COMMERCIAL":
      case "COMMERCIAL+CONSUMER":
        C.cboAccountType.ListFromCsvString(mRecord_Options.AccountTypesCommercial);
        break;

      default:
        C.cboAccountType.ListFromCsvString(mRecord_Options.AccountTypesConsumer);
        break;
    }

    // Reset Dropdown if list is now different
    if(!C.cboAccountType.ListExists(C.cboAccountType.Text())) {
      C.cboAccountType.Text("");
    }
  }
}

// ==========
// cboProduct
// ==========
function cboProduct_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  if (C.cboProduct.Text()) {
    widget.GetString("GetClientSummary", { branchId: C.cboBranch.Text(), product: C.cboProduct.Text() },
      function(data) {
        C.wbClientSummary.SetContent(data, false);
      },
      function(errorMessage) {
        widget.UI.MsgBoxAlert(errorMessage);
      }
    );
  }
}

// ===============
// chkAccessSeeker
// ===============
function chkAccessSeeker_Change() {
  C.txtFileAccessRef.ReadOnly(!C.chkAccessSeeker.Value());
}

// ==================
// chkIncludePassport
// ==================
function chkIncludePassport_Change() {
  if(C.chkIncludePassport.Value()) {
    C.chkIncludeVisa.Value(!C.chkIncludePassport.Value());
  }
}

// ==============
// chkIncludeVisa
// ==============
function chkIncludeVisa_Change() {
  if(C.chkIncludeVisa.Value()) {
    C.chkIncludePassport.Value(!C.chkIncludeVisa.Value());
  }
}

// ===============
// chkUseReference
// ===============
function chkUseReference_Change() {
  C.cboCreditBureauReference.ReadOnly(!C.chkUseReference.Value());
}

// ========================
// Create Finish Parameters
// ========================
function CreateFinishParameters() {
  var ScoreCards;
  switch(C.cboProduct.Text().toUpperCase()) {
    case "VEDASCORE APPLY":
      ScoreCards = C.chklstApplyScorecards.Text();
      break;

    case "SCORESEEKER":
      ScoreCards = C.chklstScoreSeekerScorecards.Text();
      break;

    default:
  }

  var params = {
    accessSeeker: C.chkAccessSeeker.Value(),
    accountType: C.cboAccountType.Text(),
    amountSought: C.numAmountSought.Value(),
    asynchronousEnquiry: C.chkAsynchronousEnquiry.Value(),
    branchId: C.cboBranch.Text(),
    creditBureauReference: C.cboCreditBureauReference.Text(),
    creditReviewEnquiry: C.chkCreditReviewEnquiry.Value(),
    fileAccessRef: C.txtFileAccessRef.Text(),
    hasConsent: C.chkHasConsent.Value(),
    includeDriversLicence: C.chkIncludeDriversLicence.Value(),
    includeMedicare: C.chkIncludeMedicare.Value(),
    includePassport: C.chkIncludePassport.Value(),
    includeVisa: C.chkIncludeVisa.Value(),
    permission: C.cboPermissionType.Text(),
    product: C.cboProduct.Text(),
    relationship: C.cboRelationship.Text(),
    scoreCards: ScoreCards,
    useReference: C.chkUseReference.Value(),
    enquiryId: C.txtEnquiryId.Text()
  };

  return params;
}

// =================
// Execute an Action
// =================
function Form_ExecuteAction(actionId) {
  switch (actionId.toUpperCase()) {
    case "FINISH":
      // Finish
      Form_ExecuteAction_Finish();
      break;

    default:
      window.alert(mViewName + ".Form_ExecuteAction: Unhandled action '" + actionId + "'");
      break;
  }
}

function Form_ExecuteAction_Finish() {
  widget.Close();
}

// ===========
// Resize Form
// ===========
function Form_Resize() {
  // Tab
  tabWizard_Resize();
}

// ===========
// pageOptions
// ===========
function pageOptions_Refresh() {
  // Disable form to prevent controls 'flickering' as they update
  frmMain.Visible(false);

  // Hide all
  C.lblEnquiryDetails.VisibleRow(false);
  C.txtEnquiryId.VisibleRow(false);
  C.chkHasConsent.VisibleRow(false);
  C.cboAccountType.VisibleRow(false);
  C.cboRelationship.VisibleRow(false);
  C.numAmountSought.VisibleRow(false);

  C.lblEnquiryOptions.VisibleRow(false);
  C.cboPermissionType.VisibleRow(false);
  C.chkCreditReviewEnquiry.VisibleRow(false);
  C.chklstApplyScorecards.VisibleRow(false);
  C.chklstScoreSeekerScorecards.VisibleRow(false);
  C.chkAccessSeeker.VisibleRow(false);
  C.txtFileAccessRef.VisibleRow(false);
  C.chkIncludeDriversLicence.VisibleRow(false);
  C.chkIncludeMedicare.VisibleRow(false);
  C.chkIncludePassport.VisibleRow(false);
  C.chkIncludeVisa.VisibleRow(false);

  C.lblDetails.VisibleRow(false);
  C.chkUseReference.VisibleRow(false);
  C.cboCreditBureauReference.VisibleRow(false);

  C.lblTestOptions.VisibleRow(false);
  C.chkAsynchronousEnquiry.VisibleRow(false);

  // Show relevant options
  switch(C.cboProduct.Text().toUpperCase()) {
    case "VEDASCORE APPLY":
      pageOptions_Refresh_VedaScoreApply();
      break;

    case "IDMATRIX":
      pageOptions_Refresh_IDMatrix();
      break;
      
    case "IDMATRIX PREVIOUS ENQUIRY":
      pageOptions_Refresh_IDMatrix_PreviousReport();
      break;

    case "SCORESEEKER":
      pageOptions_Refresh_ScoreSeeker();
      break;

    default:
      window.alert(C.cboProduct.Text() + " not handled!");
  }
}

function pageOptions_Refresh_GetData() {
  var params = {
    branchId: C.cboBranch.Text(),
    product: C.cboProduct.Text()
  }

  widget.GetString("GetOptions", params, pageOptions_Refresh_GetData_Done, function(errorMessage) {
    widget.UI.MsgBoxAlert(errorMessage);
  });
}

function pageOptions_Refresh_GetData_Done(data) {
  mRecord_Options = JSON.parse(data);

  // Lists
  C.cboAccountType.ListFromCsvString(mRecord_Options.AccountTypes);
  C.cboRelationship.ListFromCsvString(mRecord_Options.Relationships);
  C.cboPermissionType.ListFromCsvString(mRecord_Options.Permissions);
  C.cboCreditBureauReference.ListFromCsvString(mRecord_Options.BureauReference);
  C.chklstApplyScorecards.ListFromCsvString(mRecord_Options.ApplyScorecards);        
  C.chklstScoreSeekerScorecards.ListFromCsvString(mRecord_Options.ScoreSeekerScorecards);

  // Control Visibility
  if(!mRecord_Options.AllowDriversLicenceCheck) C.chkIncludeDriversLicence.VisibleRow(false);
  if(!mRecord_Options.AllowMedicareCheck) C.chkIncludeMedicare.VisibleRow(false);
  if(!mRecord_Options.AllowPassportCheck) C.chkIncludePassport.VisibleRow(false);
  if(!mRecord_Options.AllowVisaCheck) C.chkIncludeVisa.VisibleRow(false);
  if(C.cboProduct.Text() == "IDMatrix" &amp;&amp; !mRecord_Options.AllowDriversLicenceCheck &amp;&amp; !mRecord_Options.AllowMedicareCheck &amp;&amp; !mRecord_Options.AllowPassportCheck &amp;&amp; !mRecord_Options.AllowVisaCheck) {
    C.lblEnquiryOptions.VisibleRow(false);
  }
  C.chklstApplyScorecards.VisibleRow(mRecord_Options.DisplayApplyScorecards);
  C.chklstScoreSeekerScorecards.VisibleRow(mRecord_Options.DisplayScoreSeekerScorecards);

  // Set Fields
  C.numAmountSought.Value(0);
  C.cboCreditBureauReference.Text(mRecord_Options.BureauReference);
  C.cboPermissionType.Text(mRecord_Options.DefaultPermission);
  C.cboRelationship.Text(mRecord_Options.DefaultRelationship);
  C.chklstApplyScorecards.Text(mRecord_Options.DefaultApplyScorecards);
  C.chklstScoreSeekerScorecards.Text(mRecord_Options.DefaultScoreSeekerScorecards);        

  // Change Events
  if(C.cboPermissionType.Visible) {
    cboPermissionType_Change();
  }

  // Show content
  frmMain.Visible(true);

  // Focus
  tabWizard.FocusFirst();
}

function pageOptions_Refresh_IDMatrix() {
  // Show Controls
  C.lblEnquiryDetails.VisibleRow(true);
  C.chkHasConsent.VisibleRow(true);

  C.lblEnquiryOptions.VisibleRow(true);
  C.chkIncludeDriversLicence.VisibleRow(true);
  C.chkIncludeMedicare.VisibleRow(true);
  C.chkIncludePassport.VisibleRow(true);
  C.chkIncludeVisa.VisibleRow(true);

  // Defaults
  C.chkIncludeDriversLicence.Value(true);
  C.chkIncludeMedicare.Value(true);

  // Refresh Data
  pageOptions_Refresh_GetData();
}

function pageOptions_Refresh_IDMatrix_PreviousReport() {
  // Show Controls
  C.lblEnquiryDetails.VisibleRow(true);
  C.txtEnquiryId.VisibleRow(true);

  // Refresh Data
  pageOptions_Refresh_GetData();
}

function pageOptions_Refresh_ScoreSeeker() {
  // Show Controls
  C.lblEnquiryDetails.VisibleRow(true);
  C.cboAccountType.VisibleRow(true);
  C.cboRelationship.VisibleRow(true);
  C.numAmountSought.VisibleRow(true);

  C.lblEnquiryOptions.VisibleRow(true);
  C.cboPermissionType.VisibleRow(true);
  C.chkCreditReviewEnquiry.VisibleRow(true);
  C.chklstScoreSeekerScorecards.VisibleRow(true);
  C.chkAccessSeeker.VisibleRow(true);
  C.txtFileAccessRef.VisibleRow(true);

  C.lblTestOptions.VisibleRow(true);
  C.chkAsynchronousEnquiry.VisibleRow(true);

  // Change Events
  chkAccessSeeker_Change();

  // Refresh Data
  pageOptions_Refresh_GetData();
}

function pageOptions_Refresh_VedaScoreApply() {
  // Show Controls
  C.lblEnquiryDetails.VisibleRow(true);
  C.cboAccountType.VisibleRow(true);
  C.cboRelationship.VisibleRow(true);
  C.numAmountSought.VisibleRow(true);

  C.lblEnquiryOptions.VisibleRow(true);
  C.cboPermissionType.VisibleRow(true);
  C.chkCreditReviewEnquiry.VisibleRow(true);
  C.chklstApplyScorecards.VisibleRow(true);
  C.lblDetails.VisibleRow(true);
  C.chkUseReference.VisibleRow(true);
  C.cboCreditBureauReference.VisibleRow(true);

  C.lblTestOptions.VisibleRow(true);
  C.chkAsynchronousEnquiry.VisibleRow(true);

  // Change Events
  chkUseReference_Change();

  // Refresh Data
  pageOptions_Refresh_GetData();
}

// ===============
// Perform Enquiry
// ===============
function PerformEnquiry(successCallback) {
  // Block UI
  widget.UI.Block("Performing Enquiry, please wait...");

  // Save parameters
  mLastFinishParametersJson = JSON.stringify(CreateFinishParameters());

  // Perform Enquiry
  widget.GetString("PerformEnquiry", CreateFinishParameters(), function (data) { PerformEnquiry_Success(data, successCallback); }, PerformEnquiry_Fail);
}

function PerformEnquiry_Success(data, successCallback) {
  // Parse
  mEnquiryDetails = JSON.parse(data);

  // Show Enquiry Details
  C.wbSummary.SetContent(mEnquiryDetails.Html, false);

  // Unblock UI
  widget.UI.Unblock();

  // Callback
  successCallback();

  // Show warning
  if (mEnquiryDetails.Warning) widget.UI.MsgBoxAlert(mEnquiryDetails.Warning);

  // Refresh Parent (to show updated details)
  widget.RefreshParent();
}

function PerformEnquiry_Fail(error) {
  // Unblock UI
  widget.UI.Unblock();

  widget.UI.MsgBoxAlert(error);
}

// =========
// tabWizard
// =========
function tabWizard_Cancel() {
  widget.Close();
}

function tabWizard_Move(direction) {
  var Ok;

  // Validate
  if (direction &gt; 0) {
    tabWizard_Validate(function () { tabWizard_MovePost(direction); });
  }
  else {
    // Can always move backwards
    tabWizard_MovePost(direction);
  }
}

function tabWizard_MovePost(direction) {
  var Ok = true;

  // Find Next Tab to Move To
  if (Ok) {
    var found = false;
    var newTab = tabWizard.SelectedTabIndex();

    do {
      newTab += direction;

      switch (tabWizard.GetTabIdByIndex(newTab)) {
        default:
          found = true;
          break;
      }

      // Found?
      if (found) {
        break;
      }
      else if (newTab == tabWizard.TabCount() - 1) {
        // Just in case!
        widget.UI.MsgBoxAlert("tabWizard_MovePost: Tab not handled!");
        break;
      }
    }
    while (true);

    // Refresh the New Tab
    tabWizard_Refresh(newTab);
  }
}

function tabWizard_Refresh(newTab) {
  // Moving forward onto tab, so Load information
  if (newTab &gt;= tabWizard.SelectedTabIndex()) {
    switch (tabWizard.GetTabIdByIndex(newTab)) {
      case "Options":
        pageOptions_Refresh();
        break;

      default:
        break;
    }
  }

  // Make Tab it
  tabWizard.SelectedTabIndex(newTab);

  // Tweak fields

  // Update Heading
  switch (tabWizard.SelectedTabId()) {
    case "Options":
      frmMain.RefreshHeading(tabWizard.TabCaption(tabWizard.SelectedTabId()), "Specify '" + C.cboProduct.Text() + "' options.");
      break;

    default:
      frmMain.RefreshHeading(tabWizard.TabCaption(tabWizard.SelectedTabId()), tabWizard.TabTooltipText(tabWizard.SelectedTabId()));
      break;
  }

  // Back, Next command buttons valid?
  tabWizard_UpdateButtons();

  // Resize Wizard
  tabWizard_Resize();

  // Focus
  switch (tabWizard.SelectedTabId()) {
    default:
      tabWizard.FocusFirst();
      break;
  }
}

function tabWizard_Resize() {
  switch (tabWizard.SelectedTabId()) {
    case "General":
      C.cboRecord.WidthResizeFromParent();
      C.cboProduct.WidthResizeFromParent();
      break;

    case "Options":
      C.txtFileAccessRef.WidthResizeFromParent();
      break;

    default:
      break;
  }
}

function tabWizard_UpdateButtons() {
  // Back and Next Buttons?
  if (tabWizard.TabCount() == 1) {
    cmdBack.hide();
    cmdNext.hide();
  }
  else {
    var tabIndex = tabWizard.SelectedTabIndex();
    cmdBack.prop("disabled", tabIndex &lt;= 0);
    cmdNext.prop("disabled", tabIndex &gt;= tabWizard.TabCount() - 1);
  }

  // Finish Button
  if (tabWizard.TabCount() != 1) cmdFinish.prop("disabled", !cmdNext.prop("disabled"));
}

function tabWizard_Validate(validCallback) {
  // Validate
  var Ok = tabWizard.Validate(true);

  // Other client-side validation
  if (Ok) {
    switch (tabWizard.SelectedTabId()) {
      case "General":
        // General Page has server-side validation, so do not assume default for this page
        break;

      case "Options":
        var params_Options = CreateFinishParameters()

        // Validate product-specific fields
        switch(C.cboProduct.Text().toUpperCase()) {
          case "IDMATRIX":
            if(!C.chkHasConsent.Value()) {
              Ok = false
              widget.UI.MsgBoxAlert("Consent has not been given.");
            }

          default:
            break;
        }

        if(Ok) {
          // Confirm
          if (mEnquiryDetails &amp;&amp; mLastFinishParametersJson != JSON.stringify(params_Options)) {
            // Parameters have changed so allow performing another Credit Enquiry
            mEnquiryDetails = null;
          }

          if (mEnquiryDetails) {
            // Already created so just move on
            validCallback();
          }
          else {
            var message = "Are you sure you want to perform a " + mRecord.ServiceName + " Credit Enquiry?\n\n";
            if (mRecord.WorkflowPk) {
              message += "NOTE: The Workflow Item that this Credit Enquiry is being peformed for will be completed.\n\n"
            }
            if (mRecord.TestMode) {
              message += "NOTE: You are in 'Test Mode' so no cost will be incurred."
            }
            else {
              message += "This function incurs a cost.\n\nFor more information please refer to the Terms and Conditions of your Agreement with this Service provider.";
            }
            widget.UI.MsgBoxConfirm(message, { heading: "Perform Credit Enquiry" }, function () { PerformEnquiry(validCallback); });
          }
          return;
        }
        break;

      default:
        // No validation
        validCallback();
        return;
    }
  }

  // Server-side validation
  if (Ok) {
    var params;

    switch (tabWizard.SelectedTabId()) {
      case "General":
        params = {
          branchId: C.cboBranch.Text()
        }
        break;
    }

    if (params) {
      // Disable Form
      frmMain.FormDisable("Validating");

      // Extend parameters
      params.pageId = tabWizard.SelectedTabId();

      // Call WizardValidate method in Script
      widget.GetString("WizardValidate",
                       params,
                       function (data) { tabWizard_ValidatePost(validCallback, data); },
                       tabWizard_ValidateFail);
    }
    else {
      // No server-side validation
      validCallback();
    }
  }
}

function tabWizard_ValidatePost(validCallback, data) {
  // Enable form
  frmMain.FormEnable();

  // Parse Data
  var o = {};
  if (data) o = JSON.parse(data);

  if (o.FailedMessage) {
    // -----------------
    // Validation failed
    // -----------------
    var o = JSON.parse(data);
    widget.UI.MsgBoxAlert(o.FailedMessage);
    if (o.FailedControlId) $("#" + o.FailedControlId).focus();
  }
  else {
    // ---------------------
    // Validation successful
    // ---------------------
    // Validation could pass back additional information, e.g., to use in tabWizard_Refresh
    switch (tabWizard.SelectedTabId()) {
    }

    // Callback
    validCallback();
  }
}

function tabWizard_ValidateFail(errorMessage)
{
  widget.UI.MsgBoxAlert(errorMessage);

  // Enable form
  frmMain.FormEnable();
}

// =========
// wbSummary
// =========
function wbSummary_Refresh() {
  // Clear
  C.wbSummary.Clear();

  // Get Summary
  widget.GetString("GetServiceReport", { serviceLogPk: mEnquiryDetails.ServiceLogPk },
    function (data) {
      C.wbSummary.SetContent(data, false);
    },

    function (error) {
      widget.UI.MsgBoxAlert(error);
    }
  );
}

// ====================
// Notification Handler
// ====================
function Widget_NotificationHandler(actionId, data) {
  switch(actionId) {
    default:
      break;
  }
}
&lt;/script&gt;</TemplateText>
    <TemplateTextBookmarks />
    <TimeoutSeconds>60</TimeoutSeconds>
    <UniqueId>SE1uUtBCUE2nWqvQKxF9gQ</UniqueId>
    <AllowRefresh>true</AllowRefresh>
    <Caption />
    <HtmlWidgetAllowInitialEventCaching>false</HtmlWidgetAllowInitialEventCaching>
    <HtmlWidgetMaxHeight>800</HtmlWidgetMaxHeight>
    <HtmlWidgetMaxWidth>800</HtmlWidgetMaxWidth>
    <HtmlWidgetNeverApplyStyling>false</HtmlWidgetNeverApplyStyling>
    <HtmlWidgetResourceChartsApex>false</HtmlWidgetResourceChartsApex>
    <HtmlWidgetResourceCssSummaryPage2>false</HtmlWidgetResourceCssSummaryPage2>
    <HtmlWidgetResourceCssWidget>true</HtmlWidgetResourceCssWidget>
    <HtmlWidgetResourceJQuery>true</HtmlWidgetResourceJQuery>
    <HtmlWidgetResourceJQueryVersion />
    <HtmlWidgetSpecialEventGetFolderCount>false</HtmlWidgetSpecialEventGetFolderCount>
    <HtmlWidgetSpecialEventShowAsSummaryPage>false</HtmlWidgetSpecialEventShowAsSummaryPage>
    <HtmlWidgetSummaryPageObjectType>None</HtmlWidgetSummaryPageObjectType>
    <Icon>Logo_Equifax</Icon>
    <RestrictedOriginsListEnabled>false</RestrictedOriginsListEnabled>
    <RunAsAdministrator>false</RunAsAdministrator>
    <WebServiceName />
    <WebServiceAllowAnonymous>false</WebServiceAllowAnonymous>
    <WebServiceSendDebugInformation>false</WebServiceSendDebugInformation>
    <ShowInMenu>None</ShowInMenu>
    <ParametersType>Custom</ParametersType>
    <Parameters>
      <ISParameterDefs version="1.00">
        <Parameters>
          <Parameter name="" type="SectionStart">
            <BlankTip />
            <Caption>Form options.</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText>If you do not specify a Default Transaction Type, the Transaction Type selection will be shown regardless of the settings specified below.</TooltipText>
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="" type="SectionStart">
            <BlankTip />
            <Caption>TESTING</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText>These are the Parameters required by this HTML Widget to function correctly.
They are listed here for testing purposes only.</TooltipText>
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="ClientId" type="List">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <List>RANGE.Clients</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="AccountAppId" type="List">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <List>RANGE.AccountApps</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="AccountAppApplicantPk" type="Number">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <DecimalPlaces>0</DecimalPlaces>
            <GroupDigits>true</GroupDigits>
            <MaxValue />
            <MinValue />
            <NumberSpecialType>None</NumberSpecialType>
            <SpinChange>1</SpinChange>
          </Parameter>
          <Parameter name="BranchId" type="List">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <List>RANGE.Branches</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="WorkflowPk" type="Number">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <DecimalPlaces>0</DecimalPlaces>
            <GroupDigits>true</GroupDigits>
            <MaxValue />
            <MinValue />
            <NumberSpecialType>None</NumberSpecialType>
            <SpinChange>1</SpinChange>
          </Parameter>
          <Parameter name="WorkflowItemPk" type="Number">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <DecimalPlaces>0</DecimalPlaces>
            <GroupDigits>true</GroupDigits>
            <MaxValue />
            <MinValue />
            <NumberSpecialType>None</NumberSpecialType>
            <SpinChange>1</SpinChange>
          </Parameter>
        </Parameters>
      </ISParameterDefs>
    </Parameters>
  </finScript>