<?xml version="1.0" encoding="utf-8"?>
  <finScript version="1.00" exportedUtcDate="2023-05-28T23:46:42.0000000">
    <CreatedUserId>ADMIN</CreatedUserId>
    <CreatedUtcDate>2021-07-27T02:53:20.2330000</CreatedUtcDate>
    <UpdatedUserId>ADMIN</UpdatedUserId>
    <UpdatedUtcDate>2023-05-28T23:46:11.1070000</UpdatedUtcDate>
    <ScriptId>B2GUPDATE</ScriptId>
    <Description>PPSR B2G Update</Description>
    <ScriptType>HtmlWidget</ScriptType>
    <Active>true</Active>
    <AllowUI>false</AllowUI>
    <Bookmarks />
    <Category />
    <Code>' HtmlWidget_PPSRB2GAUUpdate
Option Explicit On
Option Strict On

' #################################################################
' PPSR B2G AU Update wizard
'
' Version: 1.04 (29/05/2023)
'
' Usage: System-defined HTML Widget
'
' NOTE: Uses Web Services Background Processes
' #################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.01  05/07/2021  ISS                
'    1.02  08/12/2021  ISS      J027840   Spelling Correction
'    1.03  29/09/2022  ISS      J029737   Implemented widget.UI.BuildBackgroundProcessProgress
'    1.04  29/05/2023  ISS      J031158   SPG field increased to 10 characters
' #################################################################

' Constants
Private Const FORM_KEY As String = "PPSRB2GAUUpdate"

' 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)

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

    Case "CancelBackgroundProcess"
      ' Cancel a Process
      Main = CancelBackgroundProcess(returnValue)

    Case "Finish"
      ' Finish wizard
      Main = Finish(parametersJson, requestInfo, returnValue)

    Case "GetCurrentProcesses"
      ' Get Current Processes
      Main = GetCurrentProcesses(returnValue)

    Case "GetBackgroundProcessStatus"
      ' Get Background Process Status
      Main = GetBackgroundProcessStatus(returnValue)

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

    Case "GetUpdateItems"
      ' Get Update Items
      Main = GetUpdateItems(parametersJson, returnValue)

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

End Function

''' &lt;summary&gt;
'''  Request that a Background Process is Cancelled.
''' &lt;/summary&gt;
Private Function CancelBackgroundProcess(ByRef returnValue As String) As Boolean

  Dim ProcessId As String
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Get Parameters
  ProcessId = mCombinedParameters.GetString("ProcessId")

  ' Request Cancel
  Success = finBL.HtmlWidgetUtilities.CancelBackgroundProcess(processId)

  Return Success

End Function

''' &lt;summary&gt;
'''  Create finSecurityRegisterB2GAUUpdateItems object.
''' &lt;/summary&gt;
Private Function CreateSecurityRegisterB2GAUUpdateItems(parameters As PPSRB2GAUUpdateParameters,
                                                        ByRef securityRegisterB2GAUUpdateItems As finSecurityRegisterB2GAUUpdateItems) As Boolean

  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise
  securityRegisterB2GAUUpdateItems = finBL.CreateSecurityRegisterB2GAUUpdateItems()

  ' Update
  With securityRegisterB2GAUUpdateItems
    ' Update
    If Success AndAlso parameters IsNot Nothing Then
        With securityRegisterB2GAUUpdateItems
          ' Parameters
          .DateDischargeClosedAccounts = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(parameters.DateDischargeClosedAccounts)
          .DateRegisterCreatedDate = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(parameters.DateRegisterCreatedDate)
          .DateRenewExpiryDate = finBL.HtmlWidgetUtilities.GetDatabaseDateFromJsonUtcDate(parameters.DateRenewExpiryDate)
          .RegistrationsAmend = parameters.RegistrationsAmend
          .RegistrationsDischarge = parameters.RegistrationsDischarge
          .RegistrationsCreate = parameters.RegistrationsCreate
          .RegistrationsRenew = parameters.RegistrationsRenew
          .IncludeAmendedSecurityStmts = parameters.IncludeAmendedSecurityStmts
          .SecuredPartyGroupId = parameters.SecuredPartyGroupId
          .RangeBranches = parameters.RangeBranches
          .RangeSecurityStmts = parameters.RangeSecurityStmts
          .RegistrationIncludeQuotes = parameters.RegistrationIncludeQuotes

          ' Refresh
          Success = .Refresh()
        End With
    End If
  End With

  Return Success

End Function

''' &lt;summary&gt;
'''  Finish, i.e., Queue Background Process.
''' &lt;/summary&gt;
''' &lt;param name="parametersJson"&gt;
'''  A JSON formatted PPSRB2GAUUpdateParameters object.
''' &lt;/param&gt;
Private Function Finish(parametersJson As String,
                        requestInfo As finScriptRequestInfo,
                        ByRef returnValue As String) As Boolean

  Dim PPSRB2GAUUpdateParameters As PPSRB2GAUUpdateParameters
  Dim ProcessId As String
  Dim SecurityRegisterB2GAUUpdateItem As finSecurityRegisterB2GAUUpdateItem
  Dim SecurityRegisterB2GAUUpdateItems As finSecurityRegisterB2GAUUpdateItems
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate

  ' Parse Parameters
  Success = GetPPSRB2GAUUpdateParameters(parametersJson, PPSRB2GAUUpdateParameters)

  ' Get PPSR B2G AU Update Object
  If Success Then
    Success = CreateSecurityRegisterB2GAUUpdateItems(PPSRB2GAUUpdateParameters, SecurityRegisterB2GAUUpdateItems)
  End If

  ' Update Included Items
  If Success Then
    For Each SecurityRegisterB2GAUUpdateItem In SecurityRegisterB2GAUUpdateItems
      With SecurityRegisterB2GAUUpdateItem
        .Include = PPSRB2GAUUpdateParameters.SecurityItemExists(.SecurityStmtPk, .SecurityStmtItemPk)
      End With
    Next

    ' Validate
    If SecurityRegisterB2GAUUpdateItems.CountInclude = 0 Then
      Success = False
      finBL.Error.ErrorBegin("You must select at least one Financing Statement to update.")
    ElseIf SecurityRegisterB2GAUUpdateItems.CountInclude &lt;&gt; PPSRB2GAUUpdateParameters.SecurityItems.Count() Then
      Success = False
      finBL.Error.ErrorBegin("Record mismatch. The collection may have changed since it was originally loaded. Please refresh the results and try again.")
    End If
  End If

  ' Queue Background Process
  If Success Then
    Success = finBL.HtmlWidgetUtilities.QueueBackgroundProcess_PPSRB2GAUUpdate(SecurityRegisterB2GAUUpdateItems, ProcessId)
  End If

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

  Return Success

End Function

''' &lt;summary&gt;
'''  Get Background Process Status.
''' &lt;/summary&gt;
Private Function GetBackgroundProcessStatus(ByRef returnValue As String) As Boolean

  Dim LastEventId As String
  Dim ProcessId As String
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Get Parameters
  With mCombinedParameters
    LastEventId = .GetString("LastEventId")
    ProcessId = .GetString("ProcessId")
  End With

  ' Get Background Processes Status including Events
  Success = finBL.HtmlWidgetUtilities.GetBackgroundProcessStatusIncludingEventsJson(processId, lastEventId, returnValue)

  Return Success

End Function

''' &lt;summary&gt;
'''  Get current and recent Background Processes that for this User (these  are also returned in GetInitialisationInfo).
''' &lt;/summary&gt;
Private Function GetCurrentProcesses(ByRef returnValue As String) As Boolean

  Dim ProcessStatuses As List(Of finHtmlWidgetUtilities.JsonProcessStatusInformation)
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Get current and recent Background Processes that for this User
  Success = finBL.HtmlWidgetUtilities.GetBackgroundProcessesJson_PPSRB2GAUUpdate(True, ProcessStatuses)

  ' Response
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(ProcessStatuses, returnValue)
  End If

  Return Success

End Function

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

  Dim FormInitialisationInfo As FormInitialisationInfo
  Dim i As Integer
  Dim ProcessStatuses As List(Of finHtmlWidgetUtilities.JsonProcessStatusInformation)
  Dim SecurityRegisterB2GAUUpdateItems As finSecurityRegisterB2GAUUpdateItems
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise

  ' Validate
  If Not finBL.Settings.AddOns.SecurityRegisterPPSR Then
    Success = False
    finBL.Error.ErrorBegin("You are not licensed for the Security Register Add-On.")
  ElseIf finBL.CountryCode &lt;&gt; "AU" Then
    Success = False
    finBL.Error.ErrorBegin("PPSR B2G AU Service is only available in Australia.")
  ElseIf finBL.SecurityRegistry Is Nothing Then
    Success = False
    finBL.Error.ErrorBegin("Security Registry interface is not initialised.")
  ElseIf finBL.Database.IsReadOnly Then
    Success = False
    finBL.Error.ErrorBegin("Access denied. Database is Read-Only.")
  End If

  ' Get PPSR B2G AU Update Object
  If Success Then
    Success = CreateSecurityRegisterB2GAUUpdateItems(Nothing, SecurityRegisterB2GAUUpdateItems)
  End If

  ' Get Initialisation Info
  If Success Then
    FormInitialisationInfo = New FormInitialisationInfo()
    With FormInitialisationInfo
      ' Record
      .B2GUpdateSecurityStmtId = mCombinedParameters.GetString("SecurityStmtId")
      .JumpToProcessIndex = -1
      With .PPSRB2GAUUpdateParameters
        .RegistrationsCreate = True
        .RegistrationsAmend = True
        .RegistrationsRenew = True
        .RegistrationsDischarge = True

        .DateDischargeClosedAccounts = finBL.HtmlWidgetUtilities.GetJsonUtcDateFromDatabaseDate(finBL.TimeZoneFunctions.GetCurrentDatabaseDate().AddDays(-1))
        .DateRenewExpiryDate = finBL.HtmlWidgetUtilities.GetJsonUtcDateFromDatabaseDate(finBL.TimeZoneFunctions.GetCurrentDatabaseDate().AddDays(1))
      End With
      .DateRenewMaxDate = finBL.HtmlWidgetUtilities.GetJsonUtcDateFromDatabaseDate(finBL.TimeZoneFunctions.GetCurrentDatabaseDate().AddMonths(3))

      ' Lists

      ' Configuration
      .TestMode = finBL.SettingsUser.CostCentreTestModeResolved

      ' Advanced Sections
      .ShowBranches = mCombinedParameters.GetString("ShowBranches") : If Len(.ShowBranches) = 0 Then .ShowBranches = "Advanced"
      .ShowSecurityStmts = mCombinedParameters.GetString("ShowSecurityStmts") : If Len(.ShowSecurityStmts) = 0 Then .ShowSecurityStmts = "Advanced"
      .ShowSecuredPartyGroups = mCombinedParameters.GetString("ShowSecuredPartyGroups") : If Len(.ShowSecuredPartyGroups) = 0 Then .ShowSecuredPartyGroups = "Advanced"

      ' Licence
      If Not finBL.Settings.AddOns.Branch Then .ShowBranches = "False"

      ' Advanced
      .PageGeneralHasAdvanced = (.ShowBranches = "Advanced" OrElse .ShowSecurityStmts = "Advanced" OrElse .ShowSecuredPartyGroups = "Advanced")

      ' Advanced Section Heading
      If .ShowBranches = "False" AndAlso .ShowSecurityStmts = "False" AndAlso .ShowSecuredPartyGroups = "False" Then
        .ShowOtherFiltersHeading = "False"
      ElseIf .ShowBranches = "True" OrElse .ShowSecurityStmts = "True" OrElse .ShowSecuredPartyGroups = "True" Then
        .ShowOtherFiltersHeading = "True"
      Else
        .ShowOtherFiltersHeading = "Advanced"
      End If

      ' Form Heading
      .FormHeading = ScriptInfo.ScriptCaption
      If Len(.FormHeading) = 0 Then .FormHeading = "PPSR B2G Update"
      If .TestMode Then .FormHeading = .FormHeading &amp; " (Test Mode)"
    End With
  End If

  ' Get current and recent Background Processes that for this User
  If Success Then
    If finBL.HtmlWidgetUtilities.GetBackgroundProcessesJson_PPSRB2GAUUpdate(True, ProcessStatuses) Then
      FormInitialisationInfo.CurrentProcesses = ProcessStatuses

      ' Get the index of a process already running specifically for this Security Statement
      If Len(FormInitialisationInfo.B2GUpdateSecurityStmtId) &lt;&gt; 0 Then
        For i = 0 To ProcessStatuses.Count - 1
          With ProcessStatuses(i)
            If Len(.Details) &lt;&gt; 0 Then
              Select Case .Status
                Case isefinCloudConnectProcessStatus.InProgress, isefinCloudConnectProcessStatus.InProgressCancelRequested, isefinCloudConnectProcessStatus.Pending
                  ' Pending or In Progress
                  If InStr(.Details, "'" &amp; FormInitialisationInfo.B2GUpdateSecurityStmtId &amp; "'", CompareMethod.Text) &lt;&gt; 0 Then
                    FormInitialisationInfo.JumpToProcessIndex = i
                    Exit For
                  End If
              End Select
            End If
          End With
        Next
      End If
    Else
      Success = False
    End If
  End If

  ' Serialise
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(FormInitialisationInfo, returnValue)
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Get PPSR B2G AU Update Parameters.
''' &lt;/summary&gt;
Private Function GetPPSRB2GAUUpdateParameters(parametersJson As String,
                                              ByRef PPSRB2GAUUpdateParameters As PPSRB2GAUUpdateParameters) As Boolean

  Dim obj As Object
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise ByRef Parameters
  PPSRB2GAUUpdateParameters = Nothing

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

  Return Success

End Function

''' &lt;summary&gt;
'''  Get Update Items.
''' &lt;/summary&gt;
Private Function GetUpdateItems(parametersJson As String,
                                ByRef returnValue As String) As Boolean

  Dim SecurityRegisterB2GAUUpdateItem As finSecurityRegisterB2GAUUpdateItem
  Dim SecurityRegisterB2GAUUpdateItems As finSecurityRegisterB2GAUUpdateItems
  Dim Success As Boolean
  Dim PPSRB2GAUUpdateParameters As PPSRB2GAUUpdateParameters
  Dim UpdateItems As List(Of UpdateItem)

  ' Assume Success
  Success = True

  ' Initialise
  UpdateItems = New List(Of UpdateItem)

  ' Parse Parameters
  Success = GetPPSRB2GAUUpdateParameters(parametersJson, PPSRB2GAUUpdateParameters)

  ' Get PPSR B2G AU Update Object and refresh
  If Success Then
    Success = CreateSecurityRegisterB2GAUUpdateItems(PPSRB2GAUUpdateParameters, SecurityRegisterB2GAUUpdateItems)
  End If

  ' Add to Collection
  If Success Then
    For Each SecurityRegisterB2GAUUpdateItem In SecurityRegisterB2GAUUpdateItems
      UpdateItems.Add(New UpdateItem(SecurityRegisterB2GAUUpdateItem))
    Next
  End If

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

  Return Success

End Function



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

  ' Current Processes
  Public CurrentProcesses As New List(Of finHtmlWidgetUtilities.JsonProcessStatusInformation)

  ' Record
  Public B2GUpdateSecurityStmtId As String
  Public JumpToProcessIndex As Integer
  Public PPSRB2GAUUpdateParameters As New PPSRB2GAUUpdateParameters()
  Public DateRenewMaxDate As Date

  ' Lists

  ' Advanced
  Public PageGeneralHasAdvanced As Boolean
  Public ShowBranches As String
  Public ShowSecuredPartyGroups As String
  Public ShowSecurityStmts As String
  Public ShowOtherFiltersHeading As String

  ' Configuration
  Public FormHeading As String
  Public TestMode As Boolean

End Class



''' &lt;summary&gt;
'''  PPSR B2G AU Update Parameters.
''' &lt;/summary&gt;
Public Class PPSRB2GAUUpdateParameters

  Public DateDischargeClosedAccounts As Date?
  Public DateRegisterCreatedDate As Date?
  Public DateRenewExpiryDate As Date?
  Public RegistrationsAmend As Boolean
  Public RegistrationsDischarge As Boolean
  Public RegistrationsCreate As Boolean
  Public RegistrationsRenew As Boolean
  Public IncludeAmendedSecurityStmts As Boolean
  Public SecuredPartyGroupId As String
  Public RegistrationIncludeQuotes As Boolean

  Public RangeBranches As String
  Public RangeSecurityStmts As String

  Public SecurityItems As New List(Of SecurityItem)

  ''' &lt;summary&gt;
	'''  Determines if a Security Statement and Security Item combination exists in the collection.
	''' &lt;/summary&gt;
	''' &lt;returns&gt;&lt;/returns&gt;
  Public Function SecurityItemExists(securityStmtPk As Integer,
                                     securityStmtItemPk As Integer) As Boolean

    Dim SecurityItem As SecurityItem

    For Each SecurityItem In Me.SecurityItems
      With SecurityItem
        If .SecurityStmtPk = securityStmtPk AndAlso .SecurityStmtItemPk = securityStmtItemPk Then
          Return True
        End If
      End With
    Next

    Return False

  End Function

End Class



''' &lt;summary&gt;
'''  A Security Statement &amp; Item Combination. Used for indicating which items to update.
''' &lt;/summary&gt;
Public Class SecurityItem

  Public SecurityStmtPk As Integer
  Public SecurityStmtItemPk As Integer

End Class



''' &lt;summary&gt;
'''  Update Item.
''' &lt;/summary&gt;
Public Class UpdateItem

  Public CanInclude As Boolean
  Public DateExpiry As Date?
  Public Description As String
  Public Icon As String
  Public Include As Boolean
  Public RegisterAction As String
  Public RegisterActionStatus As String
  Public RegisterStatus As String
  Public SecurityStmtId As String
  Public SecurityStmtPk As Integer
  Public SecurityStmtItemPk As Integer
  Public Warnings As String
  Public WarningsIncludeErrors As Boolean

  Public Sub New(securityRegisterB2GAUUpdateItem As finSecurityRegisterB2GAUUpdateItem)

    With securityRegisterB2GAUUpdateItem
      Me.CanInclude = (Not .WarningsIncludeErrors AndAlso Not .Processed)
      Me.DateExpiry = finBLShared.HtmlWidgetUtilities.GetNullableJsonUtcDateTimeFromDatabaseDateTime(.DateExpiry)
      Me.Description = .Description
      Me.Include = .Include
      Me.RegisterAction = .RegisterActionText
      Me.RegisterActionStatus = .RegisterActionStatusText
      Me.RegisterStatus = .RegisterStatusText
      Me.SecurityStmtId = .SecurityStmtId
      Me.SecurityStmtPk = .SecurityStmtPk
      Me.SecurityStmtItemPk = .SecurityStmtItemPk
      Me.Warnings = .WarningsText
      Me.WarningsIncludeErrors = .WarningsIncludeErrors

      ' Icon
      If Me.CanInclude AndAlso Len(Me.Warnings) = 0 Then
        Me.Icon = "Blank"
      ElseIf Me.WarningsIncludeErrors Then
        Me.Icon = "Error"
      Else
        Me.Icon = "Warning"
      End If
    End With

  End Sub

End Class



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

  Public ProcessId As String

  Public Sub New(processId As String)

    Me.ProcessId = processId

  End Sub

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

Used as a finPOWER Connect Cloud compatible version of the form "PPSRB2GAUUpdate".</Notes>
    <PermissionKeyExecute />
    <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="CurrentProcesses" tooltipText="Drilldown to view the status of current and recent PPSR B2G AU Updates you have run."&gt;Recent PPSR B2G AU Updates&lt;/li&gt;
        &lt;li tabId="General" tooltipText="Select the update criteria for Collateral Registrations, Amendments and Discharges."&gt;B2G Update Selection&lt;/li&gt;
        &lt;li tabId="UpdateItems" tooltipText="Financing Statements to be updated."&gt;Update Items&lt;/li&gt;
        &lt;li tabId="Progress" tooltipText="Processing progress."&gt;Progress&lt;/li&gt;
      &lt;ul&gt;
    &lt;/div&gt;
  &lt;/header&gt;

  &lt;!-- Pages --&gt;
  &lt;div class="is-widget-form-body"&gt;
    &lt;!-- Current Processes --&gt;
    &lt;div id="pageCurrentProcesses"&gt;
      &lt;div id="gridCurrentProcesses"&gt;&lt;/div&gt;
    &lt;/div&gt;

    &lt;!-- General --&gt;
    &lt;div id="pageGeneral"&gt;
      &lt;table class="is-form"&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="lblRegisterNew"&gt;Do you want to create new Collateral Registrations?&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkRegistrationsCreate" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkRegistrationIncludeQuotes" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th class="indent1"&gt;&lt;label for="dateRegisterCreatedDate"&gt;Created:&lt;/label&gt;&lt;/th&gt;
          &lt;td class="indent1"&gt;&lt;input id="dateRegisterCreatedDate" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblAmend"&gt;Do you want to Amend Collateral Registrations?&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkRegistrationsAmend" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkIncludeAmendedSecurityStmts" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblDischarge"&gt;Do you want to Discharge Collateral Registrations?&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkRegistrationsDischarge" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="dateDischargeClosedAccounts"&gt;Closed:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="dateDischargeClosedAccounts" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblRenew"&gt;Do you want to Renew Collateral Registrations?&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkRegistrationsRenew" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="dateRenewExpiryDate"&gt;Expires:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="dateRenewExpiryDate" /&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr advancedId="OtherFiltersHeading"&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblOtherFilters"&gt;Optionally filter by additional criteria&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr advancedId="SecuredPartyGroups"&gt;
          &lt;th&gt;&lt;label for="cboSecuredPartyGroup"&gt;SPG:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboSecuredPartyGroup" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr advancedId="SecurityStmts"&gt;
          &lt;th&gt;&lt;label for="txtRangeSecurityStmts"&gt;Security&amp;nbsp;Statements:&amp;nbsp;&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtRangeSecurityStmts" lookupCaption="Security Statements" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr advancedId="Branches"&gt;
          &lt;th&gt;&lt;label for="txtRangeBranches"&gt;Branches:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtRangeBranches" lookupCaption="Branches" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;

    &lt;!-- Update Items --&gt;
    &lt;div id="pageUpdateItems"&gt;
      &lt;div id="gridUpdateItems" class="is-dock-fill"&gt;&lt;/div&gt;
    &lt;/div&gt;

    &lt;!-- Progress --&gt;
    &lt;div id="pageProgress" style="display:flex"&gt;
      &lt;div id="divProgress" class="progress-events"&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;!-- Form Footer --&gt;
  &lt;footer&gt;
    &lt;button id="cmdHistory" class="is-button" style="float:left"&gt;Recent&lt;/button&gt;
    &lt;button id="cmdAdvanced" class="is-button" style="float:left" title="Show/hide advanced options"&gt;Advanced&lt;/button&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_PPSRB2GAUUpdateParameters;
var mRecord_BackgroundProcessStatus;
var mRecord_CurrentProcesses;

var mFinancingStatements;

// Controls
var C = {
  //   Current Processes
  gridCurrentProcesses: null,

  //   General
  lblRegisterNew: null,
  chkRegistrationsCreate: null,
  chkRegistrationIncludeQuotes: null,
  dateRegisterCreatedDate: null,

  lblAmend: null,
  chkRegistrationsAmend: null,
  chkIncludeAmendedSecurityStmts: null,

  lblDischarge: null,
  chkRegistrationsDischarge: null,
  dateDischargeClosedAccounts: null,

  lblRenew: null,
  chkRegistrationsRenew: null,
  dateRenewExpiryDate: null,

  lblOtherFilters: null,
  cboSecuredPartyGroup: null,
  txtRangeSecurityStmts: null,
  txtRangeBranches: null,

  //   Update Items
  gridUpdateItems: null,

  //   Progress
  divProgress: null,
}

// Form
var frmMain;
var tabWizard;

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

var cmdHistory;
var cmdAdvanced;

// Other
var mAdvancedVisible = false;
var mFromRecent = false;
var mMonitoringExisting = false;
var mProcessId;

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

  // Controls
  //   General
  C.lblRegisterNew = widget.UI.Label("lblRegisterNew", {
    tooltipText: "New Collateral Registrations have a Status of 'New' and an Action of 'Register'.\n\nIf 'Include Security Statements linked to quotes' is ticked, then Security Statements where there are no linked Clients and the only linked Account is a quote, will also be included in the list.\n\nIf a date is entered then new Collateral Registrations will be restricted to Security Statements dated on or prior to the date entered.",
  });
  C.chkRegistrationsCreate = widget.UI.CheckBox("chkRegistrationsCreate", {
    caption: "Register new Collateral?",
    captionWrap: true,

    onChange: chkRegistrationsCreate_Change,
  });
  C.chkRegistrationIncludeQuotes = widget.UI.CheckBox("chkRegistrationIncludeQuotes", {
    caption: "Include Security Statements linked to quotes?",
    captionWrap: true
  });
  C.dateRegisterCreatedDate = widget.UI.DateBox("dateRegisterCreatedDate", {});

  C.lblAmend = widget.UI.Label("lblAmend", {
    tooltipText: "If 'Check for amended Security Statements' is ticked, then include Collateral Registrations that require Amending because the Security Statement has been amended (but the 'Register Action' is blank)."
  });
  C.chkRegistrationsAmend = widget.UI.CheckBox("chkRegistrationsAmend", {
    caption: "Amend Collateral Registrations?",
    captionWrap: true,

    onChange: chkRegistrationsAmend_Change,
  });
  C.chkIncludeAmendedSecurityStmts = widget.UI.CheckBox("chkIncludeAmendedSecurityStmts", {
    caption: "Check for Amended Security Statements?",
    captionWrap: true,
  });

  C.lblDischarge = widget.UI.Label("lblDischarge", {
    tooltipText: "You may discharge Collateral Registrations linked to Accounts Closed on or before the Closed Date.\n\nA Collateral Registration will only be discharged if all Accounts linked to the Security Statement are closed and the Security Statement has no linked Clients.",
  });
  C.chkRegistrationsDischarge = widget.UI.CheckBox("chkRegistrationsDischarge", {
    caption: "Discharge Collateral Registrations?",
    captionWrap: true,

    onChange: chkRegistrationsDischarge_Change,
  });
  C.dateDischargeClosedAccounts = widget.UI.DateBox("dateDischargeClosedAccounts", {});

  C.lblRenew = widget.UI.Label("lblRenew", {
    tooltipText: "You may renew Collateral Registrations that have an Expiry Date on or before the date entered.",
  });
  C.chkRegistrationsRenew = widget.UI.CheckBox("chkRegistrationsRenew", {
    caption: "Renew Collateral Registrations?",
    captionWrap: true,

    onChange: chkRegistrationsRenew_Change,
  });
  C.dateRenewExpiryDate = widget.UI.DateBox("dateRenewExpiryDate", {});

  C.lblOtherFilters = widget.UI.Label("lblOtherFilters", {});
  C.cboSecuredPartyGroup = widget.UI.DBCombo("cboSecuredPartyGroup", {
    limitToList: true,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });

  //   Progress
  C.divProgress = $("#divProgress");

  // Ranges
  for(var k in C) {
    if (k.startsWith("txtRange")) {
      C[k] = widget.UI.TextBox(k, {
        maxLength: 255,
        onButtonClick: txtRange_ButtonClick,
      });
      var buttons = [];

      // Lookup button
      buttons.push({id: "Lookup", icon: "Find", tooltipText: "Lookup"});

      // Define buttons
      C[k].ButtonsDefine(buttons);
    }
  }

  // Grids
  C.gridCurrentProcesses = widget.UI.Grid("gridCurrentProcesses", {
    docked: true,
    stickyHeader: true,
    rowNumbering: true,

    onInitialiseRow: gridCurrentProcesses_InitialiseRow,
    onRowDrilldown: gridCurrentProcesses_RowDrilldown,
  });

  C.gridUpdateItems = widget.UI.Grid("gridUpdateItems", {
    allowCellSelect: false,
    allowMultiRowSelect: true,
    docked: true,
    showRowSelectors: true,
    stickyHeader: true,
    rowNumbering: true,

    onAction: gridUpdateItems_Action,
    onBeforeCellUpdate: gridUpdateItems_BeforeCellUpdate,
    onInitialiseRow: gridUpdateItems_InitialiseRow,
    onRowDrilldown: gridUpdateItems_RowDrilldown,
  });

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

  cmdHistory = $("#cmdHistory");
  cmdHistory.click(function() { Form_ExecuteAction("Recent"); });

  cmdAdvanced = $("#cmdAdvanced");
  cmdAdvanced.click(AdvancedToggle);

  // Handle Notifications
  widget.DisableCloseButton();
  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_PPSRB2GAUUpdateParameters = null;
  mRecord_BackgroundProcessStatus = null;
  mRecord_CurrentProcesses = null;
  mFinancingStatements = 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);
      mRecord_PPSRB2GAUUpdateParameters = mRecord.PPSRB2GAUUpdateParameters;
      mRecord_CurrentProcesses = mRecord.CurrentProcesses;

      // Give Collections ability to lookup by code

      // Load Fields
      Fields_Load();

      // Notify if there are Current Processes
      var countCurrent = 0;
      if (mRecord_CurrentProcesses &amp;&amp; !mRecord.B2GUpdateSecurityStmtId) {
        for (var i = 0; i &lt; mRecord_CurrentProcesses.length; i++) {
          switch (mRecord_CurrentProcesses[i].Status) {
            case "Pending":
            case "InProgress":
            case "InProgressCancelRequested":
              countCurrent += 1;
          }
        }
      }
      if (countCurrent != 0) {
        tabWizard_Move(-1);
        widget.UI.MsgBoxInfo("There are existing PPSR B2G Updates that you have run that are not yet complete.\n\nReview and optionally monitor these or use the 'Next &gt;' button to run a new instance of PPSR B2G Update.", { heading: "PPSR B2G Update Still Running", icon: "MonitorCategory"} );
      }
    },

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

// ===========
// Load Fields
// ===========
function Fields_Load() {
  if (mRecord) {
    // Current Processes
    // NOTE: Bind here since this is the first page
    gridCurrentProcesses_Refresh();

    // General
    C.dateRegisterCreatedDate.Value(mRecord_PPSRB2GAUUpdateParameters.DateRegisterCreatedDate);
    C.dateDischargeClosedAccounts.Value(mRecord_PPSRB2GAUUpdateParameters.DateDischargeClosedAccounts);
    C.dateRenewExpiryDate.Value(mRecord_PPSRB2GAUUpdateParameters.DateRenewExpiryDate);

    if (mRecord.B2GUpdateSecurityStmtId) {
      C.chkRegistrationsCreate.Value(true);
      C.chkRegistrationIncludeQuotes.Value(true);
      C.chkRegistrationsAmend.Value(true);
      C.chkIncludeAmendedSecurityStmts.Value(true);
      C.chkRegistrationsDischarge.Value(true);
      C.chkRegistrationsRenew.Value(true);
      C.txtRangeSecurityStmts.Text(mRecord.B2GUpdateSecurityStmtId);
    }
    else {
      C.chkRegistrationsCreate.Value(mRecord_PPSRB2GAUUpdateParameters.RegistrationsCreate);
      C.chkRegistrationIncludeQuotes.Value(mRecord_PPSRB2GAUUpdateParameters.RegistrationIncludeQuotes);
      C.chkRegistrationsAmend.Value(mRecord_PPSRB2GAUUpdateParameters.RegistrationsAmend);
      C.chkIncludeAmendedSecurityStmts.Value(mRecord_PPSRB2GAUUpdateParameters.IncludeAmendedSecurityStmts);
      C.chkRegistrationsDischarge.Value(mRecord_PPSRB2GAUUpdateParameters.RegistrationsDischarge);
      C.chkRegistrationsRenew.Value(mRecord_PPSRB2GAUUpdateParameters.RegistrationsRenew);

      C.cboSecuredPartyGroup.Text(mRecord_PPSRB2GAUUpdateParameters.SecuredPartyGroupId);
      C.txtRangeSecurityStmts.Text(mRecord_PPSRB2GAUUpdateParameters.RangeSecurityStmts);
      C.txtRangeBranches.Text(mRecord_PPSRB2GAUUpdateParameters.RangeBranches);
    }
  }

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

  // Update fields
  Fields_Update();

  // Update Controls

  // Refresh Tab
  tabWizard_Refresh();
}

// ===========
// Save Fields
// ===========
function Fields_Save() {
  // General
  // Not used by this HTML Widget
}

// =============
// Update Fields
// =============
function Fields_Update() {
  // Heading
  if (mRecord) {
    widget.SetHeading(mRecord.FormHeading);
  }

  // Information Lists

  // Lists
  if (mRecord) {
    C.cboSecuredPartyGroup.RefreshFromStandardRange("SecuredPartyGroups");
  }

  // Controls
  if (mRecord) {
    C.dateRenewExpiryDate.MaxValue(mRecord.DateRenewMaxDate);

    chkRegistrationsCreate_Change();
    chkRegistrationsAmend_Change();
    chkRegistrationsDischarge_Change();
    chkRegistrationsRenew_Change();

    // Initialise Advanced
    AdvancedInitialise();
  }

  // Auto-format
  tabWizard.AutoFormatPage();

  // Update Buttons
  tabWizard_UpdateButtons();

  // Read-Only?
  if (mRecord &amp;&amp; mRecord.ReadOnly) frmMain.FormReadOnly(C, true);

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

  // Resize Tab
  tabWizard_Resize();
}

// ===========
// Resize Form
// ===========
function Form_Resize() {
  // General

  // Tab
  tabWizard_Resize();
}

// ==============
// Wizard Buttons
// ==============
function tabWizard_Cancel() {
  // Executing?
  if (mRecord_BackgroundProcessStatus &amp;&amp; !mMonitoringExisting) {
    widget.UI.MsgBoxConfirm("PPSR B2G Update is still running.\n\nThis will continue to run and you can re-open this form at any time to check on its status.\n\n\Close this form?", {}, tabWizard_Cancel_Post);
  }
  else {
    tabWizard_Cancel_Post();
  }
}

function tabWizard_Cancel_Post() {
  if (widget.CanClose()) {
    widget.Close();
  }
  else {
    widget.Reset();
  }
}

function tabWizard_UpdateButtons() {
  var tabIndex = tabWizard.SelectedTabIndex();

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

  // Page Exceptions
  if (mRecord_BackgroundProcessStatus) {
    cmdNext.prop("disabled", tabIndex &gt;= tabWizard.TabCount() - 1);
    cmdBack.prop("disabled", true);
    cmdHistory.prop("disabled", true);

    switch(mRecord_BackgroundProcessStatus.Status) {
      case "Pending":
      case "InProgress":
        cmdFinish.text("Stop");
        cmdFinish.prop("disabled", false);
        cmdFinish.addClass("negative");
        break;

      default:
        cmdFinish.text("Process");
        cmdFinish.prop("disabled", true);
        cmdFinish.removeClass("negative");
    }
  }
  else {
    cmdFinish.text("Process");
    cmdFinish.prop("disabled", !cmdNext.prop("disabled"));
    cmdHistory.prop("disabled", false);
  }

  // Only show Advanced button on relevant pages
  if (mRecord) {
    cmdAdvanced.hide()
    switch (tabWizard.SelectedTabId()) {
      case "General":
        if (mRecord.PageGeneralHasAdvanced) cmdAdvanced.show();
        break;
    }
  }
  else {
    cmdAdvanced.hide();
  }

  // B2G Update Exceptions
  if (mRecord.B2GUpdateSecurityStmtId) {
    cmdHistory.hide();

    if (tabWizard.SelectedTabId() == "UpdateItems") {
      cmdBack.prop("disabled", true);
    }
  }

  // Recent Page exceptions
  if (mFromRecent) {
    cmdHistory.prop("disabled", false);

    cmdBack.prop("disabled", true);
    cmdNext.prop("disabled", true);
    cmdFinish.prop("disabled", true);
  }
}

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

      // Ranges
      for(var k in C) {
        if (k.startsWith("txtRange")) {
          C[k].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 "UpdateItems":
        pageUpdateItems_Refresh();
        break;

      default:
        break;
    }
  }

  // Always Refresh Current Processes, even when moving back
  if (newTab == 0) {
    if (!mRecord_CurrentProcesses) pageCurrentProcesses_Refresh();
  }

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

  // Special
  switch(tabWizard.SelectedTabId()) {
    case "General":
      if (mRecord.B2GUpdateSecurityStmtId) {
        if (mRecord.JumpToProcessIndex == -1) {
          // No Process running
          tabWizard_Move(1);
        }
        else {
          // Process already running
          ShowProcessStatus(mRecord.JumpToProcessIndex);
        }
      }
      break;

    case "CurrentProcesses":
      // Reset from recent flag
      mFromRecent = false;
      break;

    default:
      break;
  }

  // Tweak fields

  // Update Heading
  switch (tabWizard.SelectedTabId()) {
    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
        if (!C.chkRegistrationsCreate.Value() &amp;&amp; !C.chkRegistrationsAmend.Value() &amp;&amp; !C.chkRegistrationsDischarge.Value() &amp;&amp; !C.chkRegistrationsRenew.Value()) {
          Ok = false;
          widget.UI.MsgBoxAlert("At least one action (Register, Amend, Discharge or Renew) must be selected to continue.");
        }
        break;

      case "UpdateItems":
        // Update Items
        var securityStmtPks = CreateFinishParameters_SelectedItems();
        if (securityStmtPks.length == 0) {
          Ok = false;
          widget.UI.MsgBoxAlert("There are no Collateral Registrations flagged for Update.");
        }
        break;

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

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

    switch (tabWizard.SelectedTabId()) {
      default:
        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()) {
      case "General":
        // General
        if (o.Data &amp;&amp; o.Data.length != 0) {
          // Confirm warnings
          widget.UI.MsgBoxConfirmList("To continue, please approve the following:",
                                      o.Data,
                                      {
                                        heading: "Additional Confirmation",
                                        icon: "Warning",
                                      },
                                      function () { validCallback(); },
                                      null);

          // Allow callbacks to continue
          return;
        };

        break;
    }

    // Callback
    validCallback();
  }
}

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

  // Enable form
  frmMain.FormEnable();
}

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

    case "RECENT":
      // Recent
      tabWizard_Refresh(0);
      break;

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

// =============
// Finish Action
// =============
function Form_ExecuteAction_Finish() {
  if (cmdFinish.text() == "Stop") {
    // Stop Process?
    widget.UI.MsgBoxConfirm("Are you sure you want to stop this process?\n\nNOTE: This may not take affect immediately.", {}, function () { Form_ExecuteAction_FinishStop(); }, null);
  }
  else {
    // Validate
    tabWizard_Validate(function () {
      // Build Message
      var message = "Send Collateral Registration Updates to the PPSR B2G";

      // Test Mode
      if (mRecord.TestMode) {
        message += " (Test Mode)?";
      }
      else {
        message += "?";
      }

      // Background Process
      message += "\n\nNOTE: You can close this form and any time and open it again to monitor the status of this process.";

      // Confirm
      var options = {
        heading: "Process PPSR Updates?",
        icon: "Logo_PPSR_AU",
      }
      widget.UI.MsgBoxConfirm(message, options, function () { Form_ExecuteAction_FinishPost(); }, null);
    });
  }
}

function Form_ExecuteAction_FinishPost() {
  // Running new process
  mMonitoringExisting = false;

  // Clear Progress Page
  pageProgress_Refresh(true);

  // Disable Form
  widget.UI.Block("Starting PPSR B2G Update, please wait...");

  // Create Parameters
  var params = CreateFinishParameters();

  // Finish
  widget.GetString("Finish", params,
    function (data) {
      // Parse
      data = JSON.parse(data);

      // Set Tab
      tabWizard.SelectedTabId("Progress");
      tabWizard_Refresh();

      // Save Status
      mProcessId = data.ProcessId;
      mRecord_BackgroundProcessStatus = data;

      // Update Wizard Buttons
      tabWizard_UpdateButtons();

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

      // Refresh Progress
      pageProgress_Refresh();

      // Poll Background Process
      window.setTimeout(Form_ExecuteAction_GetBackgroundProcessStatus, 3500);
    },

    function (error) {
      // Show Error
      widget.UI.MsgBoxAlert(error);

      // Enable Form
      widget.UI.Unblock();
    }
  );
}

function Form_ExecuteAction_FinishStop() {
  // Continue
  widget.GetString("CancelBackgroundProcess", { processId: mProcessId },
    function (data) {
      widget.UI.MsgBoxInfo("The process has been requested to stop.");
    },

    function (error) {
      // Show Error
      widget.UI.MsgBoxAlert(error);
    }
  );
}

function Form_ExecuteAction_GetBackgroundProcessStatus() {
  // Continue
  widget.GetString("GetBackgroundProcessStatus", { processId: mProcessId, lastEventId: mLastEventId },
    function (data) {
      data = JSON.parse(data);

      // Update Status
      mRecord_BackgroundProcessStatus = data;

      // Refresh Progress
      pageProgress_Refresh();

      // Status
      var Status = mRecord_BackgroundProcessStatus.Status;

      // Handle Status
      switch(Status) {
        case "Cancelled":
          // Cancelled
          mRecord_BackgroundProcessStatus = null;

          // Update Wizard Buttons
          tabWizard_UpdateButtons();

          // Notify
          widget.UI.MsgBoxInfo("PPSR B2G Update was successfully cancelled.");
          break;

        case "Complete":
        case "CompleteWithErrors":
        case "CompleteWithWarnings":
          // Complete
          mRecord_BackgroundProcessStatus = null;

          // Update Wizard Buttons
          tabWizard_UpdateButtons();

          // Notify
          widget.UI.MsgBoxInfo("PPSR B2G Update is " + widget.SplitWordsAtCapitals(Status, true, true) + ".");
          break;

        case "Failed":
          // Failed
          mRecord_BackgroundProcessStatus = null;

          // Update Wizard Buttons
          tabWizard_UpdateButtons();

          // Notify
          widget.UI.MsgBoxAlert("PPSR B2G Update failed to complete.");
          break;

        default:
          // Continue Polling
          window.setTimeout(Form_ExecuteAction_GetBackgroundProcessStatus, 2500);

          // Prevent finPOWER Connect Cloud UI signing the User out
          widget.NotifyBusy();
      }
    },

    function (error) {
      // Show Error
      widget.UI.MsgBoxAlert(error);

      // Abort Execution
      mRecord_BackgroundProcessStatus = null;

      // Update Wizard Buttons
      tabWizard_UpdateButtons();
    }
  );
}

// ====================
// pageCurrentProcesses
// ====================
function pageCurrentProcesses_Refresh() {
  // Block UI
  widget.UI.Block("Refreshing Recent PPSR B2G Updates, please wait...");

  // Fetch
  widget.GetString("GetCurrentProcesses", {},
    function (data) {
      // Parse
      mRecord_CurrentProcesses = JSON.parse(data);

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

      // Update Wizard Buttons
      tabWizard_UpdateButtons();

      // Refresh Grid
      gridCurrentProcesses_Refresh();
    },

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

      // Show Error
      widget.UI.MsgBoxAlert(error);
    }
  );
}

// ===============
// pageUpdateItems
// ===============
function pageUpdateItems_Refresh() {
  // Hide content
  frmMain.Visible(false);

  // Block UI
  widget.UI.Block("Getting Financing Statements, please wait...")

  // Parameters
  var params = CreateFinishParameters();

  // Get Financing Statements
  widget.GetString("GetUpdateItems", params,
    // Success
    function(data) {
      // Parse
      mFinancingStatements = JSON.parse(data);

      // Unblock
      widget.UI.Unblock();

      // Close Widget here if running for a Security Statement and there are no items
      if (mRecord.B2GUpdateSecurityStmtId &amp;&amp; mFinancingStatements.length == 0) {
        widget.UI.MsgBoxInfo("No items have a Register Action.", {}, tabWizard_Cancel);
      }
      else {
        // Show content
        frmMain.Visible(true);

        // Refresh Grid
        gridUpdateItems_Refresh();
      }
    },

    // Fail
    function(errorMessage) {
      // Unblock
      widget.UI.Unblock();

      // Cancel
      tabWizard_Move(-1);

      // Show content
      frmMain.Visible(true);

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

// ============
// pageProgress
// ============
function pageProgress_Refresh(clear) {
  if (clear) {    
    mLastProcessStatus = "";
    mLastEventId = "";
    mRecord_BackgroundProcessStatus = null;
    mRecord_CurrentProcesses = null;
  }
  else if (mRecord_BackgroundProcessStatus) {
    // Retrieve Last Process Status
    mLastProcessStatus = mRecord_BackgroundProcessStatus.StatusText;
  }

  // Build Progress
  mLastEventId = widget.UI.BuildBackgroundProcessProgress(C.divProgress, clear, mRecord_BackgroundProcessStatus);

  // Stop button valid?
  tabWizard_UpdateButtons()

  // Update Heading
  if (tabWizard.SelectedTabId() == "Progress") {
    if (mLastProcessStatus &amp;&amp; mLastProcessStatus.length != 0) {
      frmMain.RefreshHeading(mLastProcessStatus, "Processing progress.");
    }
    else {
      frmMain.RefreshHeading("Progress", "Processing progress.");
    }
  }
}

// ====================
// gridCurrentProcesses
// ====================
function gridCurrentProcesses_Refresh() {
  var showDetails = false;

  // Determine column visibility
  for (var i = 0; i &lt; mRecord_CurrentProcesses.length; i++) {
    var item = mRecord_CurrentProcesses[i];

    if (item.Details) {
      showDetails = true;
    }
  }

  // Add Columns
  if (C.gridCurrentProcesses.ColumnCount() == 0) {
    C.gridCurrentProcesses.AddColumnDrilldown();
    C.gridCurrentProcesses.AddColumnString("StatusText", { caption: "Status" });
    C.gridCurrentProcesses.AddColumnString("Details", { caption: "Details", visible: showDetails });
    C.gridCurrentProcesses.AddColumnDateTime("CreatedDate", { caption: "Started" });
  }

  // Refresh
  C.gridCurrentProcesses.VirtualDataRefresh(mRecord_CurrentProcesses);

  // Activate no rows
  C.gridCurrentProcesses.ActiveDataRowIndex(-1);
}

function gridCurrentProcesses_InitialiseRow(e) {
  var item = mRecord_CurrentProcesses[e.row.listIndex];

  // Update cells
  e.row.AutoBind(item);

  // Styles
  switch(item.Status) {
    case "Complete":
      e.row.cells.StatusText.colour = "green";
      break;

    case "CompleteWithErrors":
      e.row.cells.StatusText.colour = "darkred";
      break;

    case "CompleteWithWarnings":
      e.row.cells.StatusText.colour = "orange";
      break;

    case "Failed":
      e.row.cells.StatusText.colour = "red";
      break;

    case "Pending":
    case "InProgress":
    case "InProgressCancelRequested":
      e.row.bold = true;
      break;
  }
}

function gridCurrentProcesses_RowDrilldown(e) {
  ShowProcessStatus(e.row.listIndex);
}

function ShowProcessStatus(listIndex) {
  var item = mRecord_CurrentProcesses[listIndex];

  // Switch to Progress Page
  mFromRecent = true;
  mMonitoringExisting = true;
  mProcessId = item.ProcessId;
  tabWizard_Refresh(3);
  pageProgress_Refresh(true);

  // Start monitoring
  Form_ExecuteAction_GetBackgroundProcessStatus();
}

// ===============
// gridUpdateItems
// ===============
function gridUpdateItems_Refresh() {
  var showWarnings = false;

  // Show / Hide Columns
  for (var i = 0; i &lt; mFinancingStatements.length; i++) {
    var item = mFinancingStatements[i];

    // Warnings
    if (item.Warnings) showWarnings = true;
  }

  // Add Columns
  C.gridUpdateItems.ClearColumns();
  C.gridUpdateItems.AddColumnIcon("Icon", { caption: "" });
  C.gridUpdateItems.AddColumnBoolean("Include", { caption: "Include", allowEdit: true });
  C.gridUpdateItems.AddColumnCode("SecurityStmtId", { caption: "Id" });
  C.gridUpdateItems.AddColumnString("Description", { caption: "Description" });
  C.gridUpdateItems.AddColumnString("RegisterStatus", { caption: "Status" });
  C.gridUpdateItems.AddColumnString("RegisterAction", { caption: "Action" });
  C.gridUpdateItems.AddColumnString("RegisterActionStatus", { caption: "Action Status" });
  C.gridUpdateItems.AddColumnDate("DateExpiry", { caption: "Expires" });
  C.gridUpdateItems.AddColumnString("Warnings", { caption: "Errors / Warnings", visible: showWarnings });

  // Actions
  C.gridUpdateItems.Actions().Define([{ actionId: "Refresh", tooltipText:"Refresh", icon: "Refresh" },
                                      {},
                                      { actionId: "SelectUp", tooltipText:"Select all rows above and including the current row", icon: "Select_Up" },
                                      { actionId: "SelectDown", tooltipText:"Select all rows below and including the current row", icon: "Select_Down" },
                                      { actionId: "SelectAll", tooltipText:"Select all valid rows", icon: "Select_All" },
                                      { actionId: "SelectNone", tooltipText:"Select no rows", icon: "Select_None" },
                                      { actionId: "SelectChecked", tooltipText: "Select all rows that are checked to include", icon: "Select_Checked" },
                                      { actionId: "SelectUnchecked", tooltipText: "Select all rows that are not checked to include", icon: "Select_Unchecked" },
                                      {},
                                      { actionId: "Check", tooltipText: "Check selected row(s)", icon: "Checkbox_Checked" },
                                      { actionId: "Uncheck", tooltipText: "Uncheck selected row(s)", icon: "Checkbox_Unchecked" }
                                     ]);

  // Refresh
  C.gridUpdateItems.VirtualDataRefresh(mFinancingStatements);

  // Select first row
  C.gridUpdateItems.ActivateFirstDataRow();
}

function gridUpdateItems_Action(actionId) {
  switch (actionId.toUpperCase()) {
    case "REFRESH":
      pageUpdateItems_Refresh();
      break;

    case "SELECTUP":
    case "SELECTDOWN":
      var activeRowIndex = C.gridUpdateItems.ActiveDataRowListIndex();
      var indexes = [];

      for(var i = 0; i &lt; mFinancingStatements.length; i++) {
        if(mFinancingStatements[i].CanInclude) {
          if(actionId.toUpperCase() == "SELECTUP" &amp;&amp; i &lt;= activeRowIndex) {
            indexes.push(i);
          }
          else if(actionId.toUpperCase() == "SELECTDOWN" &amp;&amp; i &gt;= activeRowIndex) {
            indexes.push(i);
          }
        }
      }
      break;

    case "SELECTALL":
      var indexes = [];
      for(var i = 0; i &lt; mFinancingStatements.length; i++) {
        var item = mFinancingStatements[i];
        if(item.CanInclude) indexes.push(i);
      }
      break;

    case "SELECTNONE":
      var indexes = [];
      break;

    case "SELECTCHECKED":
    case "SELECTUNCHECKED":
      var indexes = [];

      for(var i = 0; i &lt; mFinancingStatements.length; i++) {
        var item = mFinancingStatements[i];

        if(item.CanInclude) {
          if(actionId.toUpperCase() == "SELECTCHECKED" &amp;&amp; item.Include) {
            indexes.push(i);
          }
          else if(actionId.toUpperCase() == "SELECTUNCHECKED" &amp;&amp; !item.Include) {
            indexes.push(i);
          }
        }
      }
      break;

    case "CHECK":
    case "UNCHECK":
      var selectedItems = C.gridUpdateItems.GetSelectedRowIndexes(true, true);

      for(var i = 0; i &lt; selectedItems.length; i++) {
        var item = mFinancingStatements[selectedItems[i]];
        if(item.CanInclude) item.Include = (actionId.toUpperCase() == "CHECK");
      }
      C.gridUpdateItems.VirtualDataRefresh(mFinancingStatements, true, { retainSelectedRows: true });
      break;

    default:
      break;
  }

  // Set Indexes
  if(indexes) {
    C.gridUpdateItems.SetSelectedRowIndexes(indexes, true);
  }
}

function gridUpdateItems_BeforeCellUpdate(e) {
  var item = mFinancingStatements[e.row.listIndex];

  switch(e.columnKey) {
    case "Include":
      item.Include = e.newValue;
      break;
  }
}

function gridUpdateItems_InitialiseRow(e) {
  var item = mFinancingStatements[e.row.listIndex];

  // Update cells
  e.row.AutoBind(item);

  // Invalid rows cannot be edited
  e.row.readOnly = !item.CanInclude;
  e.row.cells.Include.readOnly = !item.CanInclude;

  // Errors
  if (item.WarningsIncludeErrors) {
    e.row.cells.Warnings.colour = "red";
  }

  // Hyperlinks
  e.row.cells.SecurityStmtId.hyperlink = "app://FormShow?form=SecurityStmt&amp;id=" + widget.UI.HtmlEncode(item.SecurityStmtId);
}

function gridUpdateItems_RowDrilldown(e) {

}

// ======================
// chkRegistrationsCreate
// ======================
function chkRegistrationsCreate_Change(sender, e) {
  C.chkRegistrationIncludeQuotes.VisibleRow(C.chkRegistrationsCreate.Value());
  C.dateRegisterCreatedDate.VisibleRow(C.chkRegistrationsCreate.Value());
}

// =====================
// chkRegistrationsAmend
// =====================
function chkRegistrationsAmend_Change(sender, e) {
  C.chkIncludeAmendedSecurityStmts.VisibleRow(C.chkRegistrationsAmend.Value());
}

// =========================
// chkRegistrationsDischarge
// =========================
function chkRegistrationsDischarge_Change(sender, e) {
  C.dateDischargeClosedAccounts.VisibleRow(C.chkRegistrationsDischarge.Value());
}

// =====================
// chkRegistrationsRenew
// =====================
function chkRegistrationsRenew_Change(sender, e) {
  C.dateRenewExpiryDate.VisibleRow(C.chkRegistrationsRenew.Value());
}

// ========
// txtRange
// ========
function txtRange_ButtonClick(sender, e) {
  if (e.id == "Lookup") {
    var caption = sender.Element().attr("lookupCaption");
    var range = sender.Element().attr("id");

    range = range.substr(8);
    if(range.startsWith("Payee")) range = "ExternalParties" + range.substr(5);

    widget.UI.Forms.ShowRangeLookupFromStandardRange(range, sender.Text(), { caption: "Lookup " + caption},
      function (newRange) {
        sender.Text(newRange);
        sender.Focus();
      }
    );
  }
}

// ========================
// Create Finish Parameters
// ========================
function CreateFinishParameters() {
  var params;

  // Parameters
  params = {
    // General
    dateDischargeClosedAccounts: C.dateDischargeClosedAccounts.Value(),
    dateRegisterCreatedDate: C.dateRegisterCreatedDate.Value(),
    dateRenewExpiryDate: C.dateRenewExpiryDate.Value(),
    registrationsAmend: C.chkRegistrationsAmend.Value(),
    registrationsDischarge: C.chkRegistrationsDischarge.Value(),
    registrationsCreate: C.chkRegistrationsCreate.Value(),
    registrationsRenew: C.chkRegistrationsRenew.Value(),
    includeAmendedSecurityStmts: C.chkIncludeAmendedSecurityStmts.Value(),
    securedPartyGroupId: C.cboSecuredPartyGroup.Text(),
    registrationIncludeQuotes: C.chkRegistrationIncludeQuotes.Value(),

    // Ranges
    rangeSecurityStmts: C.txtRangeSecurityStmts.Text(),
    rangeBranches: C.txtRangeBranches.Text(),

    // Selected Items
    securityItems: CreateFinishParameters_SelectedItems(),
  }

  return params;
}

// ==================
// Get Selected Items
// ==================
function CreateFinishParameters_SelectedItems() {
  var records = [];

  if (mFinancingStatements) {
    for(var i = 0; i &lt; mFinancingStatements.length; i++) {
      var item = mFinancingStatements[i];

      if(item.Include &amp;&amp; item.CanInclude) {
        var o = {
          securityStmtPk: item.SecurityStmtPk,
          securityStmtItemPk: item.SecurityStmtItemPk,
        }
        records.push(o);
      }
    }
  }

  return records;
}

// =================
// Advanced handling
// =================
function AdvancedInitialise() {
  // Tweaks

  // General
  AdvancedInitialiseSection("OtherFiltersHeading", mRecord.ShowOtherFiltersHeading);
  AdvancedInitialiseSection("SecuredPartyGroups", mRecord.ShowSecuredPartyGroups);
  AdvancedInitialiseSection("Branches", mRecord.ShowBranches);
  AdvancedInitialiseSection("SecurityStmts", mRecord.ShowSecurityStmts);
}

function AdvancedInitialiseSection(id, option) {
  // Get elements
  var els=$("*[advancedId='" + id + "']");

  // Update
  switch(option.toUpperCase()) {
    case "TRUE":
      // Always show, i.e., not advanced
      break;

    case "FALSE":
      // Never show
      els.hide();
      break;

    case "ADVANCED":
      // Only show in 'Advanced' mode
      els.addClass("advanced");
      break;
  }
}

function AdvancedToggle() {
  // Toggle Advanced
  mAdvancedVisible = !mAdvancedVisible;

  // Update Controls
  if (mAdvancedVisible) {
    // Showing
    $("body").addClass("advanced-visible");
    cmdAdvanced.attr("showing", true);
  }
  else {
    // Not showing
    $("body").removeClass("advanced-visible");
    cmdAdvanced.attr("showing", false);
  }

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

  // Finalise
  AdvancedInitialise();

  // Force resize
  tabWizard_Resize();
}

// ====================
// Notification Handler
// ====================
function Widget_NotificationHandler(actionId, data) {
  switch(actionId.toUpperCase()) {
    case "FORMCLOSE":
      // Closing Form
      if (mRecord &amp;&amp; mRecord.WorkflowId &amp;&amp; !mSearchResult) {
        widget.UI.MsgBoxConfirm("Closing this form without performing a Search will not action the Workflow Item.\n\nAre you sure you want to close this form?", {}, tabWizard_Cancel);
      }
      else {
        tabWizard_Cancel();
      }
      break;

    case "ITEMSHOW":
      // Show a Security Item in read-only mode
      // NOTE: When following a FormAction Application Shortcut, data will always be a URL String
      widget.ExecuteApplicationShortcutUrl("FormShow?form=SecurityStmtItem&amp;" + data + "&amp;readonly=true");
      break;

    default:
      break;
  }
}
&lt;/script&gt;</TemplateText>
    <TemplateTextBookmarks />
    <TimeoutSeconds>60</TimeoutSeconds>
    <UniqueId>u4Ci2KJ+tUGDoH2xTthKiA</UniqueId>
    <AllowRefresh>true</AllowRefresh>
    <Caption />
    <HtmlWidgetMaxHeight>0</HtmlWidgetMaxHeight>
    <HtmlWidgetMaxWidth>1200</HtmlWidgetMaxWidth>
    <HtmlWidgetNeverApplyStyling>false</HtmlWidgetNeverApplyStyling>
    <HtmlWidgetResourceChartsApex>false</HtmlWidgetResourceChartsApex>
    <HtmlWidgetResourceCssSummaryPage2>false</HtmlWidgetResourceCssSummaryPage2>
    <HtmlWidgetResourceCssWidget>true</HtmlWidgetResourceCssWidget>
    <HtmlWidgetResourceJQuery>true</HtmlWidgetResourceJQuery>
    <HtmlWidgetResourceJQueryVersion />
    <HtmlWidgetSpecialEventGetFolderCount>false</HtmlWidgetSpecialEventGetFolderCount>
    <Icon>Logo_PPSR_AU</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>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="SecurityStmtId" 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.SecurityStmts</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <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="ShowSecuredPartyGroups" 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>Advanced</Value>
            <Visible>true</Visible>
            <List>True,False,Advanced</List>
            <LimitToList>true</LimitToList>
            <MaxLength>8</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="ShowBranches" 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>Advanced</Value>
            <Visible>true</Visible>
            <List>True,False,Advanced</List>
            <LimitToList>true</LimitToList>
            <MaxLength>8</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="ShowSecurityStmts" type="List">
            <BlankTip />
            <Caption>Show Security Statements</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>Advanced</Value>
            <Visible>true</Visible>
            <List>True,False,Advanced</List>
            <LimitToList>true</LimitToList>
            <MaxLength>8</MaxLength>
            <Rows>1</Rows>
          </Parameter>
        </Parameters>
      </ISParameterDefs>
    </Parameters>
  </finScript>