<?xml version="1.0" encoding="utf-8"?>
  <finScript version="1.00" exportedUtcDate="2024-09-18T01:21:15.0000000">
    <CreatedUserId>ADMIN</CreatedUserId>
    <CreatedUtcDate>2024-09-18T01:09:57.3210000</CreatedUtcDate>
    <UpdatedUserId>ADMIN</UpdatedUserId>
    <UpdatedUtcDate>2024-09-18T01:13:50.5250000</UpdatedUtcDate>
    <ScriptId>HWGIDICE</ScriptId>
    <Description>GreenId (Australia) Individual Credit Enquiry</Description>
    <ScriptType>HtmlWidget</ScriptType>
    <Active>true</Active>
    <AllowUI>false</AllowUI>
    <Bookmarks />
    <Category />
    <Code>' HtmlWidget_GreenId_Individual
Option Explicit On
Option Strict On

' ##################################################################
' GreenId (Australia) Individual Credit Enquiry wizard HTML Widget
'
' Version: 1.05 (18/09/2024)
'
' Usage: System-supplied HTML Widget
' ##################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.00  17/06/2021  ISS      J026766   Created
'    1.01  09/02/2022  ISS      J028264   Support for Drivers Licence Card Number
'    1.02  12/07/2022  ISS      J028905   Show readonly cost centre information
'    1.03  22/07/2022  ISS      J026867   Implement supported products
'          01/11/2022  ISS      J029792   'Green' Medicare cards now only allow Month &amp; Year expiry
'    1.04  16/03/2023  ISS      J030537   Default product update
'    1.05  18/09/2024  ISS      J029950   Changed the Workflow Executor to the finBL.HtmlWidgetUtilities.WorkflowItemComplete function
' #################################################################

' Constants
Private Const FORM_KEY As String = "GreenId_Individual"
Private Const SERVICE_ID As String = "GreenId"
Private Const SUPPORTED_PRODUCTS As String = "Background Check"

' 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;
'''  Get Branch Defaults.
''' &lt;/summary&gt;
Private Function GetBranchDefaults(ByRef returnValue As String) As Boolean

  Dim BranchId As String
  Dim CostCentreResolved_GreenId As finCostCentreResolved_GreenId
  Dim Data As Object
  Dim DefaultProduct As String
  Dim Success As Boolean
  Dim SupportedProducts As ISList

  ' Assume Success
  Success = True

  ' Initialise
  SupportedProducts = New ISList(SUPPORTED_PRODUCTS)
  
  ' Assume Success
  Success = True

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

  ' Get Cost Centre
  CostCentreResolved_GreenId = finBL.CostCentresResolved.ItemByBranchId(BranchId).GreenId
  
  ' Get Default Product
  DefaultProduct = ""
  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
  
  ' Object
  Data = New With {
    .DefaultProduct = DefaultProduct
  }

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

  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 FormInitialisationInfo As FormInitialisationInfo
  Dim List As ISListReadOnly
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate
  If Len(mClientId) = 0 AndAlso (Len(mAccountAppId) = 0 OrElse mAccountAppApplicantPk = 0) Then
    Success = False
    finBL.Error.ErrorBegin("Client Id or Account Application Applicant details not 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.")
  End If

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

  ' 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

        ' Get Passport Details
        Success = GetPassportDetails(Client, 0, .PassportNumber, .PassportCountry)
      End If
      If AccountApp IsNot Nothing Then
        .AccountAppId = AccountApp.AccountAppId
        .AccountAppName = AccountApp.Name
        .AccountAppApplicantPk = AccountAppApplicant.Pk
        .AccountAppApplicantName = AccountAppApplicant.Name
        .PassportNumber = AccountAppApplicant.PassportNumber

        ' Get Passport Details
        If Len(.PassportNumber) = 0 AndAlso AccountAppApplicant.ClientPk &lt;&gt; 0 Then
          Success = GetPassportDetails(Nothing, AccountAppApplicant.ClientPk, .PassportNumber, .PassportCountry)
        End If
      End If

      If Success Then
        .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
        'List = finBL.CreditBureau.GetServiceProductIdsList(SERVICE_ID, iseProductClass.CreditEnquiry, iseProductTarget.Individual, False)
        List = finBL.Runtime.CreateListReadOnly(SUPPORTED_PRODUCTS)
        .ProductsList = List.ToCsvString()

        ' Defaults
        If List.Count = 1 Then
          .DefaultProduct = List(0)
        Else
          .DefaultProduct = finBL.CreditBureau.GetServiceDefaultEnquiryProduct(SERVICE_ID, iseProductTarget.Individual, .BranchId)
          If Not List.Exists(.DefaultProduct) Then
            finBL.Trace.WriteWarning(String.Format("Default product {0} not supported by this HTML Widget.", .DefaultProduct))
            .DefaultProduct = List(0)
          End If
        End If
        .DefaultSummary = finBL.SummaryPageFunctions.BlankRecordSummary(ScriptInfo, "No Product Selected", "Please select a Product to view the Client Summary.")

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

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

  Return Success

End Function

''' &lt;summary&gt;
'''  Retrieve Passport Details.
''' &lt;/summary&gt;
Private Function GetPassportDetails(client As finClient,
                                    clientPk As Integer,
                              ByRef passportNumber As String,
                              ByRef passportCountry As String) As Boolean

  Dim ClientIdentificationItem As finClientIdentificationItem
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise ByRef Parameters
  passportNumber = ""
  passportCountry = ""

  ' Load Client if required
  If client Is Nothing Then
    client = finBL.CreateClient()
    Success = client.LoadPk(clientPk)
  End If

  ' Get Passport Information
  If Success Then
    For Each ClientIdentificationItem In client.IdentificationItems
      With ClientIdentificationItem
        Select Case .IdentificationType.SpecialType
          Case isefinIdentificationTypeSpecialType.AU_Passport
            passportCountry = "AUS"
            passportNumber = .AU_Passport.DocumentNumber
            Exit For

          Case isefinIdentificationTypeSpecialType.NZ_Passport
            passportCountry = "NZL"
            passportNumber = .NZ_Passport.PassportNumber
            Exit For

          Case isefinIdentificationTypeSpecialType.US_Passport
            passportCountry = "USA"
            passportNumber = .US_Passport.PassportNumber
            Exit For

        End Select
      End With
    Next
  End If

  Return Success

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;
'''  Get a finClient and, optionally, a finAccountAppApplicant object from Web Service properties.
''' &lt;/summary&gt;
''' &lt;returns&gt;
'''  A Boolean value indicating success.
''' &lt;/returns&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 DriversLicenceCardNumber As String
  Dim DriversLicenceNumber As String
  Dim DriversLicenceState As String
  Dim Html As String
  Dim MedicareCardColour As String
  Dim MedicareCardExpiryDate As Date
  Dim MedicareCardNumber As String
  Dim MedicareIndividualReferenceNumber As String
  Dim MedicareNameOnCard As String
  Dim PassportNumber As String
  Dim Product As String
  Dim sb As finHtmlSummaryPage2StringBuilder
  Dim ShowContactDetails As Boolean
  Dim ShowDriversLicence 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
    Select Case CreditEnquiryRequest.GetType()
      Case GetType(ISCreditEnquiryRequest_GreenId_BackgroundCheck)
        ' Show Sections
        ShowContactDetails = True
        ShowDriversLicence = True
        ShowMedicare = True
        ShowPassport = True

        ' Get Fields
        With DirectCast(CreditEnquiryRequest, ISCreditEnquiryRequest_GreenId_BackgroundCheck)
          ContactPhone = .PhoneHome
          ContactMobile = .PhoneMobile
          ContactWorkPhone = .PhoneWork
          ContactEmail = .Email

          DriversLicenceState = .AUDvsDriversLicenceState
          DriversLicenceNumber = .AUDvsDriversLicenceNumber
          DriversLicenceCardNumber = .AUDvsDriversLicenceCardNumber

          MedicareCardColour = .AUDvsMedicareCardColour
          MedicareCardExpiryDate = .AUDvsMedicareCardExpiryDate
          MedicareCardNumber = .AUDvsMedicareCardNumber
          MedicareIndividualReferenceNumber = .AUDvsMedicareIndividualReferenceNumber
          MedicareNameOnCard = .AUDvsMedicareNameOnCard
        End With

      Case Else
        finBL.Error.ErrorBeginFormat("Unhandled Product '{0}'.", Product)
        Success = False
    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()

      If Len(creditEnquiryRequest.ProductWarning) &lt;&gt; 0 Then
        .TextBefore = "{{warning|" &amp; creditEnquiryRequest.ProductWarning &amp; "}}"
      End If
      .TextBefore &amp;= "{{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)

        ' Date of Birth
        If CreditEnquiryRequest.DateOfBirth = Nothing Then
          .AddCaptionWiki("Date of Birth:", "{{warning|Date of Birth not specified.}}")
        Else
          .AddCaptionDate("Date of Birth:", CreditEnquiryRequest.DateOfBirth)
        End If

        ' Gender
        If Len(CreditEnquiryRequest.Gender) = 0 Then
          .AddCaptionWiki("Gender:", "{{warning|Gender not specified.}}")
        Else
          .AddCaptionText("Gender:", CreditEnquiryRequest.Gender)
        End If

        ' 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("Australian Driver's Licence details")
          If Len(DriversLicenceState) = 0 AndAlso Len(DriversLicenceNumber) = 0 Then
            .AddWiki("{{warning|Australian Drivers Licence details not found.}}")
          Else
            ' State
            If Len(DriversLicenceState) = 0 Then
              .AddCaptionWiki("State:", "{{warning|State not specified.}}")
            Else
              .AddCaptionText("State:", DriversLicenceState)
            End If

            ' Licence Number
            If Len(DriversLicenceNumber) = 0 Then
              .AddCaptionWiki("Licence No:", "{{warning|Licence Number not specified.}}")
            Else
              .AddCaptionText("Licence No:", DriversLicenceNumber)
            End If

            ' Card Number
            If Len(DriversLicenceCardNumber) = 0 Then
              .AddCaptionWiki("Card No:", "{{warning|Card Number not specified.}}")
            Else
              .AddCaptionText("Card No:", DriversLicenceCardNumber)
            End If
          End If
        End If

        ' Medicare
        If ShowMedicare Then
          .AddSectionHeading2("Australian Medicare details")
          If Len(MedicareCardNumber) = 0 AndAlso Len(MedicareIndividualReferenceNumber) = 0 AndAlso Len(MedicareCardColour) = 0 AndAlso MedicareCardExpiryDate = Nothing Then
            .AddWiki("{{warning|Australian Medicare details not found.}}")
          Else
            ' Medicare No
            If Len(MedicareCardNumber) = 0 Then
              .AddCaptionWiki("Medicare No:", "{{warning|Medicare Number not specified.}}")
            Else
              .AddCaptionText("Medicare No:", MedicareCardNumber)
            End If

            ' IRN
            If Len(MedicareIndividualReferenceNumber) = 0 Then
              .AddCaptionWiki("IRN:", "{{warning|Individual Reference Number not specified.}}")
            Else
              .AddCaptionText("IRN:", MedicareIndividualReferenceNumber)
            End If

            ' Colour
            If Len(MedicareCardColour) = 0 Then
              .AddCaptionWiki("Colour:", "{{warning|Colour not specified.}}")
            Else
              .AddCaptionText("Colour:", MedicareCardColour)
            End If

            ' Expiry
            If MedicareCardExpiryDate = Nothing Then
              .AddCaptionWiki("Expiry:", "{{warning|Expiry not specified.}}")
            Else              
              If UCase(MedicareCardColour) = "G" Then
                .AddCaptionText("Expiry:", Format(MedicareCardExpiryDate, "MM/yyyy"))
              Else 
                .AddCaptionDate("Expiry:", MedicareCardExpiryDate)
              End If  
            End If

            ' Name on Card
            .AddCaptionText("Name on Card:", MedicareNameOnCard)
          End If
        End If

        ' Passport
        If ShowPassport Then
          .AddSectionHeading2("Australian Passport details")
          If Len(PassportNumber) = 0 Then
            .AddWiki("{{warning|Australian Passport details not found.}}")
          Else
            .AddCaptionText("Passport No:", PassportNumber)
          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 Options.
''' &lt;/summary&gt;
Private Function GetOptions(parametersJson As String,
                            ByRef returnValue As String) As Boolean

  Dim AllowAUDVSDriversLicenceCheck As Boolean
  Dim AllowAUDVSMedicareCardCheck As Boolean
  Dim AllowAUDVSPassportCheck As Boolean
  Dim AllowAUDVSVisaCheck As Boolean
  Dim AllowDnBCreditHeaderCheck As Boolean
  Dim BranchId As String
  Dim CodeDescriptionList As ISCodeDescriptionList
  Dim CostCentreResolved_GreenId As finCostCentreResolved_GreenId
  Dim CreditEnquiryRequest As ISCreditEnquiryRequest
  Dim Data As Object
  Dim PerformDnBCreditHeader As Boolean
  Dim PerformDvsDriversLicence As Boolean
  Dim PerformDvsMedicare As Boolean
  Dim PerformDvsPassport As Boolean
  Dim PerformDvsVisa As Boolean
  Dim Product As String
  Dim Success As Boolean

  ' Assume Success
  Success = True

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

  ' Create Request for this Product
  CreditEnquiryRequest = finBL.CreditBureau.CreateCreditEnquiryRequest(SERVICE_ID, iseProductClass.CreditEnquiry, Product, BranchId)
  finBL.CreditBureau.UpdateCreditEnquiryRequestOptions(CreditEnquiryRequest, Nothing)

  ' Ensure selected Branch is used
  If Len(BranchId) &lt;&gt; 0 AndAlso finBL.Branches.Exists(BranchId) Then
    CreditEnquiryRequest.BranchPk = finBL.Branches(BranchId).Pk
  End If

  ' Get Cost Centre
  CostCentreResolved_GreenId = finBL.CostCentresResolved.ItemByBranchId(BranchId).GreenId

  ' Product-specific options
  Select Case CreditEnquiryRequest.GetType()
    Case GetType(ISCreditEnquiryRequest_GreenId_BackgroundCheck)
      ' ================
      ' Background Check
      ' ================
      Dim Request As ISCreditEnquiryRequest_GreenId_BackgroundCheck

      ' Cost Centre Rules
      With CostCentreResolved_GreenId
        AllowAUDVSDriversLicenceCheck = .CreditEnquiryAllowAUDVSDriversLicenceCheck
        AllowAUDVSMedicareCardCheck = .CreditEnquiryAllowAUDVSMedicareCardCheck
        AllowAUDVSPassportCheck = .CreditEnquiryAllowAUDVSPassportCheck
        AllowAUDVSVisaCheck = .CreditEnquiryAllowAUDVSVisaCheck
        AllowDnBCreditHeaderCheck = .CreditEnquiryAllowDnBCreditHeaderCheck
      End With

      ' Request Details
      Request = DirectCast(CreditEnquiryRequest, ISCreditEnquiryRequest_GreenId_BackgroundCheck)
      With Request
        PerformDvsDriversLicence = (.PerformAUBackgroundCheck_DvsDriversLicence AndAlso AllowAUDVSDriversLicenceCheck)
        PerformDvsMedicare = (.PerformAUBackgroundCheck_DvsMedicare AndAlso AllowAUDVSMedicareCardCheck)
        PerformDvsPassport = (.PerformAUBackgroundCheck_DvsPassport AndAlso AllowAUDVSPassportCheck)
        PerformDvsVisa = (.PerformAUBackgroundCheck_DvsVisa AndAlso AllowAUDVSVisaCheck)
        PerformDnBCreditHeader = (.PerformBackgroundCheck_DnBCreditHeader AndAlso AllowDnBCreditHeaderCheck)

        CodeDescriptionList = .VisaCountryOfIssue.ToCodeDescriptionList()
      End With

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

  ' Get Response Object
  If Success Then
    Data = New With {
      .AllowAUDVSDriversLicenceCheck = AllowAUDVSDriversLicenceCheck,
      .AllowAUDVSMedicareCardCheck = AllowAUDVSMedicareCardCheck,
      .AllowAUDVSPassportCheck = AllowAUDVSPassportCheck,
      .AllowAUDVSVisaCheck = AllowAUDVSVisaCheck,
      .AllowDnBCreditHeaderCheck = AllowDnBCreditHeaderCheck,
      .PerformDvsDriversLicence = PerformDvsDriversLicence,
      .PerformDvsMedicare = PerformDvsMedicare,
      .PerformDvsPassport = PerformDvsPassport,
      .PerformDvsVisa = PerformDvsVisa,
      .PerformDnBCreditHeader = PerformDnBCreditHeader,
      .VisaCountryOfIssue = CodeDescriptionList.ToJsonObject()
    }
  End If

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

  Return Success

End Function

''' &lt;summary&gt;
'''  Perform Enquiry.
''' &lt;/summary&gt;
''' &lt;param name="parametersJson"&gt;
'''  A JSON formatted WizardFinishParameters object.
''' &lt;/param&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 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_GreenId_BackgroundCheck)
      ' ================
      ' Background Check
      ' ================
      Dim Request As ISCreditEnquiryRequest_GreenId_BackgroundCheck

      Request = DirectCast(CreditEnquiryRequest, ISCreditEnquiryRequest_GreenId_BackgroundCheck)
      With Request
        .DnBCreditHeaderConsentGiven = WizardFinishParameters.ConsentGiven
        .PerformAUBackgroundCheck_DvsDriversLicence = WizardFinishParameters.IncludeDriversLicenceCheck
        .PerformAUBackgroundCheck_DvsMedicare = WizardFinishParameters.IncludeMedicareCheck
        .PerformAUBackgroundCheck_DvsPassport = WizardFinishParameters.IncludeAustralianPassportCheck
        .PerformAUBackgroundCheck_DvsVisa = WizardFinishParameters.IncludeVisaCheck
        .PerformBackgroundCheck_DnBCreditHeader = WizardFinishParameters.IncludeDNBCheck

        .AUDvsVisaCountryOfIssue = WizardFinishParameters.VisaCountryOfIssue
        .AUDvsVisaPassportNumber = WizardFinishParameters.VisaPassportNumber
      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
    strTemp = ""
    finBL.HtmlWidgetUtilities.WorkflowItemComplete(mStartupParameters, strTemp)
    
    If Len(strTemp) &lt;&gt; 0 Then
      Warnings.Add("The Enquiry was 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;
'''  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;
'''  Validate a Wizard page.
''' &lt;/summary&gt;
''' &lt;param name="parametersJson"&gt;
'''  A JSON formatted object containing information required to validate a Wizard page.
''' &lt;/param&gt;
''' &lt;param name="returnValue"&gt;
'''  A JSON object; "true" if validation passed, otherwise, information as to why validation failed.
''' &lt;/param&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 PassportCountry As String
  Public PassportNumber As String

  Public WorkflowPk As Integer

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

  ' Defaults
  Public DefaultProduct As String
  Public DefaultSummary As String

  ' Configuration
  Public ServiceName As String
  Public AllowBranch As Boolean
  Public ShowBranch As Boolean
  Public TestMode 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



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

  ' General
  Public BranchId As String
  Public Product As String

  ' Options
  Public ConsentGiven As Boolean
  Public IncludeDriversLicenceCheck As Boolean
  Public IncludeMedicareCheck As Boolean
  Public IncludeAustralianPassportCheck As Boolean
  Public IncludeVisaCheck As Boolean
  Public IncludeDNBCheck As Boolean
  Public VisaCountryOfIssue As String
  Public VisaPassportNumber As String

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</Code>
    <Language>VisualBasic</Language>
    <Notes>System defined HTML Widget.

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

The following products are supported:
* Background Check</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 colspan="2"&gt;&lt;input id="chkConsentGiven" type="checkbox"/&gt;&lt;/th&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 colspan="2"&gt;&lt;input id="chkIncludeDriversLicenceCheck" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkIncludeMedicareCheck" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkIncludeAustralianPassportCheck" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkIncludeVisaCheck" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th class="indent1"&gt;&lt;label for="cboVisaCountry"&gt;Country:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboVisaCountry" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th class="indent1"&gt;&lt;label for="txtVisaPassportNumber"&gt;Passport No.:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtVisaPassportNumber" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkIncludeDNBCheck" 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_Options;
var mRecord_BranchDefaults;
var mEnquiryDetails;
var mLastProductLoaded;

// 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,
  chkConsentGiven: null,

  lblEnquiryOptions: null,
  chkIncludeDriversLicenceCheck: null,
  chkIncludeMedicareCheck: null,
  chkIncludeAustralianPassportCheck: null,
  chkIncludeVisaCheck: null,
  cboVisaCountry: null,
  txtVisaPassportNumber: null,
  chkIncludeDNBCheck: null,

  // Enquiry
  wbSummary: null,
}

// Form
var frmMain;
var tabWizard;

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

// Other
var mLastBranch = "";
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.chkConsentGiven = widget.UI.CheckBox("chkConsentGiven", {
    caption: "Has consent been obtained from the subject of the Enquiry?",
    captionWrap: true,

    onChange: chkConsentGiven_Change,
  });

  C.lblEnquiryOptions = widget.UI.Label("lblEnquiryOptions", {});
  C.chkIncludeDriversLicenceCheck = widget.UI.CheckBox("chkIncludeDriversLicenceCheck", {
    caption: "Include Driver's Licence (DVS) check?",
    captionWrap: true,
  });
  C.chkIncludeMedicareCheck = widget.UI.CheckBox("chkIncludeMedicareCheck", {
    caption: "Include Medicare (DVS) check?",
    captionWrap: true,
  });
  C.chkIncludeAustralianPassportCheck = widget.UI.CheckBox("chkIncludeAustralianPassportCheck", {
    caption: "Include Australian Passport (DVS) check?",
    captionWrap: true,
  });
  C.chkIncludeVisaCheck = widget.UI.CheckBox("chkIncludeVisaCheck", {
    caption: "Include Visa (DVS) check?",
    captionWrap: true,

    onChange: chkIncludeVisaCheck_Change,
  });
  C.cboVisaCountry = widget.UI.DBCombo("cboVisaCountry", {
    allowBlank: false,
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.txtVisaPassportNumber = widget.UI.TextBox("txtVisaPassportNumber", {
    allowBlank: false,
  });
  C.txtVisaPassportNumber
  C.chkIncludeDNBCheck = widget.UI.CheckBox("chkIncludeDNBCheck", {
    caption: "Include Dun and Bradstreet Credit Header check?",
    captionWrap: true,
  });

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

  // 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_Options = null;
  mLastProductLoaded = 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);

    // Visa Country
    C.cboVisaCountry.Text(mRecord.PassportCountry);
    C.txtVisaPassportNumber.Text(mRecord.PassportNumber);
  }

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

  // Update Controls

  // Update fields
  Fields_Update();

  // Refresh Tab
  tabWizard_Refresh();
}

// ===========
// Save Fields
// ===========
function Fields_Save() {
  // Not used by this wizard since there is no concept of updating an object behind the wizard
}

// =============
// 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);
    
    cboBranch_Change();
    cboProduct_Change();
    chkConsentGiven_Change();
  }

  // Update Buttons
  tabWizard_UpdateButtons();

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

  // Resize Tab
  tabWizard_Resize();
}

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

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

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"));
}

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

    case "Options":
      C.cboVisaCountry.WidthResizeFromParent();
      C.txtVisaPassportNumber.WidthResizeFromParent();
      break;

    default:
      break;
  }
}

// ===========
// Wizard Move
// ===========
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);
  }
}

// ===========
// Refresh Tab
// ===========
function tabWizard_Refresh(newTab) {
  // Moving forward onto tab, so Load information
  if (newTab &gt;= tabWizard.SelectedTabIndex()) {
    switch (tabWizard.GetTabIdByIndex(newTab)) {
      case "Options":
        // Load options if product has changed
        if (mLastProductLoaded != C.cboProduct.Text()) {
          pageOptions_Refresh();
        }
        break;

      default:
        break;
    }
  }

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

  // Tweak fields

  // Update Heading
  switch (tabWizard.SelectedTabId()) {
    case "General":
      frmMain.RefreshHeading(mRecord.ServiceName + " Individual Credit Enquiry", tabWizard.TabTooltipText(tabWizard.SelectedTabId()));
      break;

    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;
  }
}

// ===============
// Validate Wizard
// ===============
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":
        // Consent
        if (C.cboProduct.Text() == "Background Check" &amp;&amp; !C.chkConsentGiven.Value()) {
          Ok = false;
          widget.UI.MsgBoxAlert("Consent must be obtained from the subject of the Enquiry.");
        }

        // Confirm
        if (Ok) {
          if (mEnquiryDetails &amp;&amp; mLastFinishParametersJson != JSON.stringify(CreateFinishParameters())) {
            // 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();
}

// ===============
// 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);
}

// =================
// 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;
  }
}

// =============
// Finish Action
// =============
function Form_ExecuteAction_Finish() {
  widget.Close();
}

function CreateFinishParameters() {
  var params = {
    BranchId: C.cboBranch.Text(),
    Product: C.cboProduct.Text(),

    ConsentGiven: C.chkConsentGiven.Value(),
    IncludeDriversLicenceCheck: C.chkIncludeDriversLicenceCheck.Value(),
    IncludeMedicareCheck: C.chkIncludeMedicareCheck.Value(),
    IncludeAustralianPassportCheck: C.chkIncludeAustralianPassportCheck.Value(),
    IncludeVisaCheck: C.chkIncludeVisaCheck.Value(),
    IncludeDNBCheck: C.chkIncludeDNBCheck.Value(),
  };

  // Visa
  if (C.chkIncludeVisaCheck.Value()) {
    params.VisaCountryOfIssue = C.cboVisaCountry.Text();
    params.VisaPassportNumber = C.txtVisaPassportNumber.Text();
  }

  return params;
}

// ====================
// Notification Handler
// ====================
function Widget_NotificationHandler(actionId, data) {
  switch(actionId) {
//    case "BankAccountEnquiry.Refresh":
//      // Refresh report
//      wbSummary_Refresh();
//      break;
  }
}

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

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

// ===========
// pageOptions
// ===========
function pageOptions_Refresh() {
  // Hide all
  C.lblEnquiryDetails.VisibleRow(false);
  C.chkConsentGiven.VisibleRow(false);

  C.lblEnquiryOptions.VisibleRow(false);
  C.chkIncludeDriversLicenceCheck.VisibleRow(false);
  C.chkIncludeMedicareCheck.VisibleRow(false);
  C.chkIncludeAustralianPassportCheck.VisibleRow(false);
  C.chkIncludeVisaCheck.VisibleRow(false);
  C.chkIncludeDNBCheck.VisibleRow(false);

  // Show relevant options
  switch(C.cboProduct.Text().toUpperCase()) {
    case "BACKGROUND CHECK":
      pageOptions_Refresh_BackgroundCheck();
      break;

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

function pageOptions_Refresh_BackgroundCheck() {
  // Show controls
  C.lblEnquiryDetails.VisibleRow(true);
  C.chkConsentGiven.VisibleRow(true);

  // Parameters
  var params = {
    BranchId: C.cboBranch.Text(),
    Product: C.cboProduct.Text(),
  }

  // Get defaults for Controls
  widget.GetString("GetOptions", params, pageOptions_Refresh_BackgroundCheck_Done, function(errorMessage) {
    // Unblock
    widget.UI.Unblock();

    // Error
    widget.UI.MsgBoxAlert(errorMessage);
  });
}

function pageOptions_Refresh_BackgroundCheck_Done(data) {
  // Parse
  mRecord_Options = JSON.parse(data);

  // Set Values
  C.chkIncludeDriversLicenceCheck.Value(mRecord_Options.PerformDvsDriversLicence);
  C.chkIncludeMedicareCheck.Value(mRecord_Options.PerformDvsMedicare);
  C.chkIncludeAustralianPassportCheck.Value(mRecord_Options.PerformDvsPassport);
  C.chkIncludeVisaCheck.Value(mRecord_Options.PerformDvsVisa);
  C.chkIncludeDNBCheck.Value(mRecord_Options.PerformDnBCreditHeader);

  // Update Controls
  C.cboVisaCountry.RefreshFromCodeDescriptionList(mRecord_Options.VisaCountryOfIssue);

  // Update Controls
  chkConsentGiven_Change();

  // Set this Product as last loaded
  mLastProductLoaded = C.cboProduct.Text();
}

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

// === Default Product not used in this HTML Widget ===
// Get Default Product
//  widget.GetString("GetBranchDefaults", { branchId: C.cboBranch.Text() },
//    // Success
//    function(data) {
//      mRecord_BranchDefaults = JSON.parse(data);
//
//      if(mRecord_BranchDefaults) {
//        // Set Default Product
//        C.cboProduct.Text(mRecord_BranchDefaults.DefaultProduct);
//      }
//    },
//
//    // 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();
  }
}

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

  // Clear last loaded
  mLastProductLoaded = null;

  // Update Summary
  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);
      }
    );
  }
  else {
    C.wbClientSummary.SetContent(mRecord.DefaultSummary, false);
  }
}

// ===============
// chkConsentGiven
// ===============
function chkConsentGiven_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  var AllowAUDVSDriversLicenceCheck = false;
  var AllowAUDVSMedicareCardCheck = false;
  var AllowAUDVSPassportCheck = false;
  var AllowAUDVSVisaCheck = false;
  var AllowDnBCreditHeaderCheck = false;

  if (mRecord_Options) {
    AllowAUDVSDriversLicenceCheck = mRecord_Options.AllowAUDVSDriversLicenceCheck;
    AllowAUDVSMedicareCardCheck = mRecord_Options.AllowAUDVSMedicareCardCheck;
    AllowAUDVSPassportCheck = mRecord_Options.AllowAUDVSPassportCheck;
    AllowAUDVSVisaCheck = mRecord_Options.AllowAUDVSVisaCheck;
    AllowDnBCreditHeaderCheck = mRecord_Options.AllowDnBCreditHeaderCheck;
  }

  // Update Controls
  C.chkIncludeDriversLicenceCheck.VisibleRow(C.chkConsentGiven.Value() &amp;&amp; AllowAUDVSDriversLicenceCheck);
  C.chkIncludeMedicareCheck.VisibleRow(C.chkConsentGiven.Value() &amp;&amp; AllowAUDVSMedicareCardCheck);
  C.chkIncludeAustralianPassportCheck.VisibleRow(C.chkConsentGiven.Value() &amp;&amp; AllowAUDVSPassportCheck);
  C.chkIncludeVisaCheck.VisibleRow(C.chkConsentGiven.Value() &amp;&amp; AllowAUDVSVisaCheck);
  C.chkIncludeDNBCheck.VisibleRow(C.chkConsentGiven.Value() &amp;&amp; AllowDnBCreditHeaderCheck);

  C.lblEnquiryOptions.VisibleRow(C.chkIncludeDriversLicenceCheck.VisibleRow() || C.chkIncludeMedicareCheck.VisibleRow() || C.chkIncludeAustralianPassportCheck.VisibleRow() || C.chkIncludeVisaCheck.VisibleRow() || C.chkIncludeDNBCheck.VisibleRow());

  chkIncludeVisaCheck_Change();
}

// ===================
// chkIncludeVisaCheck
// ===================
function chkIncludeVisaCheck_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  // Update Controls
  C.cboVisaCountry.VisibleRow(C.chkConsentGiven.Value() &amp;&amp; C.chkIncludeVisaCheck.Value());
  C.txtVisaPassportNumber.VisibleRow(C.chkConsentGiven.Value() &amp;&amp; C.chkIncludeVisaCheck.Value());
}
&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_GreenId</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>