<?xml version="1.0" encoding="utf-8"?>
  <finScript version="1.00" exportedUtcDate="2023-05-23T23:59:15.0000000">
    <CreatedUserId>ADMIN</CreatedUserId>
    <CreatedUtcDate>2022-11-16T03:59:39.0400000</CreatedUtcDate>
    <UpdatedUserId>ADMIN</UpdatedUserId>
    <UpdatedUtcDate>2023-05-23T23:57:10.0370000</UpdatedUtcDate>
    <ScriptId>ITE</ScriptId>
    <Description>Identification Type Edit</Description>
    <ScriptType>HtmlWidget</ScriptType>
    <Active>true</Active>
    <AllowUI>false</AllowUI>
    <Bookmarks />
    <Category />
    <Code>' HtmlWidget_IdentificationTypeEdit
Option Explicit On
Option Strict On

' #################################################################
' Identification Type Edit form HTML Widget
'
' Version: 1.01 (24/05/2023)
'
' Usage: System-supplied HTML Widget
' #################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.00  18/11/2022  ISS      J027921   Created
'    1.01  24/05/2023  ISS      J031152   Improved Paste Name &amp; Date of Birth checkbox display
' #################################################################

' Constants
Private Const FORM_KEY As String = "IdentificationTypes"

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

' Standard Parameters
Private mIdentificationTypeId As String
Private mDuplicateRecordId As String
Private mPage As String
Private mReadOnly As Boolean

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 Standard Parameters
  With mStartupParameters
    mIdentificationTypeId = .GetString("IdentificationTypeId") ' Always use Startup Parameters since the Identification Type Id may be updated
  End With
  With mCombinedParameters
    mDuplicateRecordId = .GetString("DuplicateRecordId")
    mPage = .GetString("Page")
    mReadOnly = .GetBoolean("ReadOnly")
  End With

  ' Validate
  Main = finBL.HtmlWidgetUtilities.HasPermissionToViewFormKey(FORM_KEY)

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

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

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

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

End Function

''' &lt;summary&gt;
'''  Load Identification Type.
''' &lt;/summary&gt;
Private Function GetIdentificationType(ByRef identificationType As finIdentificationType) As Boolean

  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate

  ' Create and Load Identification Type
  If Success Then
    ' Create Identification Type
    identificationType = finBL.CreateIdentificationType()

    ' Load Identification Type
    If Len(mDuplicateRecordId) &lt;&gt; 0 Then
      ' New record (by duplicating existing)
      Success = identificationType.Load(mDuplicateRecordId)
      If Success Then identificationType.Duplicate()
    ElseIf Len(mIdentificationTypeId) = 0 Then
      ' New record
    Else
      Success = identificationType.Load(mIdentificationTypeId)
    End If
  End If

  Return Success

End Function

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

  Dim FormInitialisationInfo As FormInitialisationInfo
  Dim IdentificationType As finIdentificationType
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate

  ' Get Identification Type
  If Success Then
    Success = GetIdentificationType(IdentificationType)
  End If

  ' Get Initialisation Info
  If Success Then
    FormInitialisationInfo = New FormInitialisationInfo()
    With FormInitialisationInfo
      ' Form
      .PageId = mPage
      If finBL.Database.IsReadOnly OrElse mReadOnly OrElse Not finBL.CurrentUser.Permissions.Allow("Admin.IdentificationTypes") Then
        .ReadOnly = True
      Else
        .ReadOnly = False
      End If

      ' Record
      .Pk = IdentificationType.Pk
      .Timestamp = IdentificationType.Timestamp

      ' Page Permissions (defined here since they are used below)
      .AllowPageGeneral = True
      .AllowPageDataEntry = True
      .AllowPageValidation = True

      ' General
      .IdentificationTypeId = IdentificationType.IdentificationTypeId ' Always need to return Identification Type Id
      If .AllowPageGeneral Then
        .Active = IdentificationType.Active
        .Description = IdentificationType.Description

        .DescriptionShort = IdentificationType.DescriptionShort

        .SpecialTypeText = IdentificationType.SpecialTypeText
        
        .EncryptDetails = IdentificationType.EncryptDetails
      End If

      ' Data Entry
      If .AllowPageDataEntry Then
        .AllowMainDetails = IdentificationType.AllowMainDetails
        .DetailsMandatory = IdentificationType.DetailsMandatory
        .DetailsToRecord = IdentificationType.DetailsToRecord
        .DetailsTooltipText = IdentificationType.DetailsTooltipText
        .AllowName = IdentificationType.AllowName
        .AllowNamePaste = IdentificationType.AllowNamePaste
        .AllowDateOfBirth = IdentificationType.AllowDateOfBirth
        .AllowDateOfBirthPaste = IdentificationType.AllowDateOfBirthPaste
        .AllowAddress = IdentificationType.AllowAddress
        .AllowReference = IdentificationType.AllowReference
        .AllowIssuer = IdentificationType.AllowIssuer
        .AllowExpiryDate = IdentificationType.AllowExpiryDate
        .DefaultExpiryCycle = IdentificationType.DefaultExpiryCycle        
        
        .InformationListIssuerId = IdentificationType.InformationListIssuerId
        .InformationListReferenceDesignationId = IdentificationType.InformationListReferenceDesignationId
      End If

      ' Validation
      If .AllowPageValidation Then
        .ValidationMethodText = IdentificationType.ValidationMethodText
        .ValidationExpression = IdentificationType.ValidationExpression
        .ValidationWarning = IdentificationType.ValidationWarning
      End If

      ' Other

      ' Permissions

      ' Lists
      .SpecialTypeList = finBL.Enums.isefinIdentificationTypeSpecialType_ToCodeDescriptionList().ToJsonObject()
      .ValidationMethodList = finBL.Enums.isefinIdentificationTypeValidationMethod_ToCodeDescriptionList().ToJsonObject()

      ' Configuration
      .HideOtherPages = mCombinedParameters.GetBoolean("HideOtherPages", False)
      .PromptOnSave = finBL.CloudConnectFunctions.CloudConnectSettings.PromptOnSave
    End With
  End If

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

  Return Success

End Function

''' &lt;summary&gt;
'''  Finish, i.e., Save Identification Type.
''' &lt;/summary&gt;
''' &lt;param name="parametersJson"&gt;
'''  A JSON formatted record (FormInitialisationInfo) object.
''' &lt;/param&gt;
Private Function Finish(parametersJson As String,
                        requestInfo As finScriptRequestInfo,
                        ByRef returnValue As String) As Boolean

  Dim IdentificationType As finIdentificationType
  Dim obj As Object
  Dim Record As FormInitialisationInfo
  Dim Success As Boolean

  ' Assume Success
  Success = True

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

  ' Get Identification Type
  If Success Then
    Success = GetIdentificationType(IdentificationType)
  End If

  ' Validate
  If Success Then
    If Record.Timestamp &lt;&gt; IdentificationType.Timestamp Then
      Success = False
      finBL.Error.ErrorBegin("This record has been updated by another User.")
    End If
  End If

  ' Update and Save
  ' NOTE: Recheck Permissions in addition to the 'AllowPage' properties before updating to prevent spoofing
  If Success Then
    ' Begin Transaction
    If finBL.Database.TransactionBegin() Then
      ' Update Identification Type
      With IdentificationType
        ' General
        If Record.AllowPageGeneral Then
          .IdentificationTypeId = Record.IdentificationTypeId
          .Active = Record.Active
          .Description = Record.Description

          .DescriptionShort = Record.DescriptionShort

          .SpecialTypeText = Record.SpecialTypeText
          
          .EncryptDetails = Record.EncryptDetails
        End If

        ' Data Entry
        If Record.AllowPageDataEntry Then
          .AllowMainDetails = Record.AllowMainDetails
          .DetailsMandatory = Record.DetailsMandatory
          .DetailsToRecord = Record.DetailsToRecord
          .DetailsTooltipText = Record.DetailsTooltipText
          .AllowName = Record.AllowName
          .AllowNamePaste = Record.AllowNamePaste
          .AllowDateOfBirth = Record.AllowDateOfBirth
          .AllowDateOfBirthPaste = Record.AllowDateOfBirthPaste
          .AllowAddress = Record.AllowAddress
          .AllowReference = Record.AllowReference
          .AllowIssuer = Record.AllowIssuer
          .AllowExpiryDate = Record.AllowExpiryDate
          .DefaultExpiryCycle = Record.DefaultExpiryCycle

          .InformationListIssuerId = Record.InformationListIssuerId
          .InformationListReferenceDesignationId = Record.InformationListReferenceDesignationId
        End If

        ' Validation
        If Record.AllowPageValidation Then
          .ValidationMethodText = Record.ValidationMethodText
          .ValidationExpression = Record.ValidationExpression
          .ValidationWarning = Record.ValidationWarning
        End If
      End With

      ' Save
      If Success Then
        Success = IdentificationType.Save()
      End If

      ' Commit/ Rollback Transaction
      If Success Then
        finBL.Database.TransactionCommit()
      Else
        finBL.Database.TransactionRollback()
      End If
    Else
      Success = False
    End If
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Validate a Wizard page.
''' &lt;/summary&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 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
    PageId = .GetString("PageId")
  End With

  ' Validate Page
  Select Case PageId
    Case "General"
      ' General
  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;
'''  Wizard Initialisation Information.
''' &lt;/summary&gt;
''' &lt;remarks&gt;
'''  This object is also used to save the Employment.
''' &lt;/remarks&gt;
Public Class FormInitialisationInfo

  ' Form
  Public PageId As String
  Public [ReadOnly] As Boolean

  ' Record
  Public Pk As Integer
  Public Timestamp As Integer

  ' General
  Public IdentificationTypeId As String
  Public Active As Boolean
  Public Description As String

  Public DescriptionShort As String

  Public SpecialTypeText As String
  
  Public EncryptDetails As Boolean

  ' Data Entry
  Public AllowMainDetails As Boolean
  Public DetailsMandatory As Boolean
  Public DetailsToRecord As String
  Public DetailsTooltipText As String
  Public AllowName As Boolean
  Public AllowNamePaste As Boolean
  Public AllowDateOfBirth As Boolean
  Public AllowDateOfBirthPaste As Boolean
  Public AllowAddress As Boolean
  Public AllowReference As Boolean
  Public AllowIssuer As Boolean
  Public AllowExpiryDate As Boolean
  Public DefaultExpiryCycle As String  

  Public InformationListIssuerId As String
  Public InformationListReferenceDesignationId As String

  ' Validation
  Public ValidationMethodText As String
  Public ValidationExpression As String
  Public ValidationWarning As String

  ' Permissions
  Public AllowPageGeneral As Boolean
  Public AllowPageDataEntry As Boolean
  Public AllowPageValidation As Boolean

  ' Lists
  Public SpecialTypeList As Object
  Public ValidationMethodList As Object

  ' Configuration
  Public HideOtherPages As Boolean
  Public PromptOnSave As Boolean

End Class



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

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

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

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

  End Sub

End Class</Code>
    <Language>VisualBasic</Language>
    <Notes>System-supplied HTML Widget to edit an Identification Type.</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;!-- Tabs --&gt;
    &lt;div id="tabDetails" class="is-tabs"&gt;
      &lt;ul&gt;
        &lt;li tabId="General"&gt;General&lt;/li&gt;
        &lt;li tabId="DataEntry"&gt;Data Entry&lt;/li&gt;
        &lt;li tabId="Validation"&gt;Validation&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"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:8em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblCodeAndName"&gt;Code and Description&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtIdentificationTypeId"&gt;Code:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtIdentificationTypeId"/&gt; &lt;input id="chkActive" type="checkbox"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtDescription"&gt;Description:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtDescription"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblDescriptionShort"&gt;Short Description&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="txtDescriptionShort"&gt;Short&amp;nbsp;Description:&amp;nbsp;&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtDescriptionShort"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblSpecialType"&gt;Identification Type&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboSpecialType"&gt;Special Type:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboSpecialType"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblEncryption"&gt;Encryption Options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkEncryptDetails" type="checkbox" /&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;div id="divEncryptMessage" class="is-info-text info"&gt;&lt;/div&gt;&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Data Entry --&gt;
    &lt;div id="pageDataEntry"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:8em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label&gt;Options&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkAllowMainDetails" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2" class="indent1"&gt;&lt;input id="chkDetailsMandatory" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th class="indent1"&gt;&lt;label for="txtDetailsToRecord"&gt;Caption:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtDetailsToRecord"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th id="thDetailsTooltipText" class="indent1"&gt;&lt;label for="txtDetailsTooltipText"&gt;Tooltip:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtDetailsTooltipText"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkAllowName" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkAllowNamePasteButton" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkAllowDateOfBirth" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkAllowDateOfBirthPasteButton" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkAllowAddress" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkAllowReference" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkAllowIssuer" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="chkAllowExpiryDate" type="checkbox"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th class="indent1"&gt;&lt;label for="cboDefaultExpiryCycle"&gt;Default:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboDefaultExpiryCycle"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblInformationLists"&gt;Information Lists&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboInformationListIssuer"&gt;Issuer:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboInformationListIssuer"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboInformationListReferenceDesignation"&gt;Reference:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboInformationListReferenceDesignation"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;



    &lt;!-- Validation --&gt;
    &lt;div id="pageValidation"&gt;
      &lt;table class="is-form"&gt;
        &lt;colgroup&gt;
          &lt;col style="width:8em" /&gt;
          &lt;col /&gt;
        &lt;/colgroup&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblValidationMethod"&gt;Validation method for main details&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboValidationMethod"&gt;Validation:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboValidationMethod"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblValidationExpression"&gt;Expression used to validate main details&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="txtValidationExpression"/&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label id="lblValidationWarning"&gt;Validation warning message&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;input id="txtValidationWarning"/&gt;&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/table&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="cmdFinish" class="is-button ok"&gt;Save&lt;/button&gt;
  &lt;/footer&gt;

&lt;/div&gt;


&lt;script&gt;
// Properties
var mRecord;

var mOriginalJson;

// Controls
var C = {
  //   General
  lblCodeAndName: null,
  chkActive: null,
  txtIdentificationTypeId: null,
  txtDescription: null,

  lblDescriptionShort: null,
  txtDescriptionShort: null,

  lblSpecialType: null,
  cboSpecialType: null,

  lblEncryption: null,
  chkEncryptDetails: null,
  divEncryptMessage: null,

  //   Data Entry
  chkAllowMainDetails: null,
  chkDetailsMandatory: null,
  txtDetailsToRecord: null,
  thDetailsTooltipText: null,
  txtDetailsTooltipText: null,

  chkAllowName: null,
  chkAllowNamePasteButton: null,
  chkAllowDateOfBirth: null,
  chkAllowDateOfBirthPasteButton: null,
  chkAllowAddress: null,
  chkAllowReference: null,
  chkAllowIssuer: null,
  chkAllowExpiryDate: null,
  cboDefaultExpiryCycle: null,

  lblInformationLists: null,
  cboInformationListIssuer: null,
  cboInformationListReferenceDesignation: null,

  //   Validation
  lblValidationMethod: null,
  cboValidationMethod: null,

  lblValidationExpression: null,
  txtValidationExpression: null,

  lblValidationWarning: null,
  txtValidationWarning: null,
}

// Form
var frmMain;
var tabDetails;

// Buttons
var cmdCancel;
var cmdFinish;

// Other

// ==========
// Initialise
// ==========
$(function () {
  // --------
  // Controls
  // --------
  //   General
  C.lblCodeAndName = widget.UI.Label("lblCodeAndName", {});
  C.txtIdentificationTypeId = widget.UI.TextBox("txtIdentificationTypeId", {
    allowBlank: false,
    maxLength: 10,
    width: widget.UI.FIELD_WIDTH_CODE_10,
  });
  C.chkActive = widget.UI.CheckBox("chkActive", {
    caption: "Active?",
  });
  C.txtDescription = widget.UI.TextBox("txtDescription", {
    allowBlank: false,
    maxLength: 50,
  });

  C.lblDescriptionShort = widget.UI.Label("lblDescriptionShort", {
    tooltipText: "Short Description is used when displaying Identification Items in grids.",
  });
  C.txtDescriptionShort = widget.UI.TextBox("txtDescriptionShort", {
    maxLength: 20,
  });

  C.lblSpecialType = widget.UI.Label("lblSpecialType", {});
  C.cboSpecialType = widget.UI.ComboBox("cboSpecialType", {
    allowBlank: false,
    limitToList: true,
    width: "12em",

    onChange: cboSpecialType_Change,
  });

  C.lblEncryption = widget.UI.Label("lblEncryption", {
    tooltipText: "Enabling Encryption will encrypt the main Detail Value stored in the Database. Existing records are not automatically encrypted, so click the 'Encrypt Now' button on the read-only version of this form in finPOWER Connect Cloud.",
  });
  C.chkEncryptDetails = widget.UI.CheckBox("chkEncryptDetails", {
    caption: "Encrypt Details?",
    
    onChange: chkEncryptDetails_Change
  });
  C.divEncryptMessage = $("#divEncryptMessage");

  //   Data Entry
  C.chkAllowMainDetails = widget.UI.CheckBox("chkAllowMainDetails", {
    caption: "Record main details",

    onChange: pageDataEntry_Refresh,
  });
  C.chkDetailsMandatory = widget.UI.CheckBox("chkDetailsMandatory", {
    caption: "Are the main details mandatory?",
  });
  C.txtDetailsToRecord = widget.UI.TextBox("txtDetailsToRecord", {
    maxLength: 30,
  });
  C.thDetailsTooltipText = $("#thDetailsTooltipText");
  C.txtDetailsTooltipText = widget.UI.TextBox("txtDetailsTooltipText", {
    maxLength: 255,
    multiLine: true,
    rows: 3,
  });
  C.chkAllowName = widget.UI.CheckBox("chkAllowName", {
    caption: "Name?",

    onChange: pageDataEntry_Refresh,
  });
  C.chkAllowNamePasteButton = widget.UI.CheckBox("chkAllowNamePasteButton", {
    caption: "Show button to paste Name from Client?",
  });
  C.chkAllowDateOfBirth = widget.UI.CheckBox("chkAllowDateOfBirth", {
    caption: "Date of Birth?",

    onChange: pageDataEntry_Refresh,
  });
  C.chkAllowDateOfBirthPasteButton = widget.UI.CheckBox("chkAllowDateOfBirthPasteButton", {
    caption: "Show button to paste Date of Birth from Client?",
  });
  C.chkAllowAddress = widget.UI.CheckBox("chkAllowAddress", {
    caption: "Address?",
  });
  C.chkAllowReference = widget.UI.CheckBox("chkAllowReference", {
    caption: "Reference details?",
  });
  C.chkAllowIssuer = widget.UI.CheckBox("chkAllowIssuer", {
    caption: "Issuer?",
  });
  C.chkAllowExpiryDate = widget.UI.CheckBox("chkAllowExpiryDate", {
    caption: "Expiry Date?",

    onChange: pageDataEntry_Refresh,
  });
  C.cboDefaultExpiryCycle = widget.UI.DateCycleComboBox("cboDefaultExpiryCycle", {});

  C.lblInformationLists = widget.UI.Label("lblInformationLists", {});
  C.cboInformationListIssuer = widget.UI.DBCombo("cboInformationListIssuer", {
    limitToList: true,
    maxLength: 50,
    width: widget.UI.FIELD_WIDTH_CODE_20,
  });
  C.cboInformationListReferenceDesignation = widget.UI.DBCombo("cboInformationListReferenceDesignation", {
    limitToList: true,
    maxLength: 50,
    width: widget.UI.FIELD_WIDTH_CODE_20,
  });

  //   Validation
  C.lblValidationMethod = widget.UI.Label("lblValidationMethod", {});
  C.cboValidationMethod = widget.UI.ComboBox("cboValidationMethod", {
    allowBlank: false,
    limitToList: true,
    width: "12em",

    onChange: cboValidationMethod_Change,
  });

  C.lblValidationExpression = widget.UI.Label("lblValidationExpression", {});
  C.txtValidationExpression = widget.UI.TextBox("txtValidationExpression", {
    maxLength: 8192,
    multiLine: true,
    rows: 6,
  });

  C.lblValidationWarning = widget.UI.Label("lblValidationWarning", {});
  C.txtValidationWarning = widget.UI.TextBox("txtValidationWarning", {
    maxLength: 8192,
    multiLine: true,
    rows: 6,
  });

  // Grids

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

  // Create Tabs
  tabDetails = new widget.UI.Tabs("tabDetails", {
    style: "normal",
    onSelectedTabChanged: tabDetails_Refresh,
  });

  // Handle resize
  $(window).resize(Form_Resize);

  // Disable Close Button (this causes the 'FormClose' notification action to be invoked instead)
  widget.DisableCloseButton();
  widget.ActionNotificationHandle(Widget_NotificationHandler)

  // Handle Wizard Buttons
  cmdCancel = $("#cmdCancel");
  cmdFinish = $("#cmdFinish");
  cmdCancel.click(tabDetails_Cancel);
  cmdFinish.click(Form_ExecuteAction_Finish);

  // Reset
  Form_Reset();
});

// ==========
// Reset Form
// ==========
function Form_Reset() {
  // Resize
  Form_Resize();

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

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

  // Hide content
  frmMain.Visible(false);

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

  // Load Initialisation details
  widget.GetString("GetInitialisationInfo", {},
    // Success
    Record_Load_Done,

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

function Record_Load_Done(data) {
  // Initialise
  mRecord = JSON.parse(data);

  // Set Tab
  if (mRecord &amp;&amp; mRecord.PageId) {
    tabDetails.SelectedTabId(mRecord.PageId);

    // Hide other Pages
    if (mRecord.HideOtherPages) {
      tabDetails.ShowSingleTab(mRecord.PageId);
    }
  }
  else {
    tabDetails.SelectedTabId("General");
  }

  // Page Permissions
  if (!mRecord.AllowPageGeneral) tabDetails.TabVisible("General", false);
  if (!mRecord.AllowPageDataEntry) tabDetails.TabVisible("DataEntry", false);
  if (!mRecord.AllowPageValidation) tabDetails.TabVisible("Validation", false);

  // Load Fields
  Fields_Load();

  // Save Fields (so UserData is in correct format for mOriginalJson)
  Fields_Save();

  // Save original JSON for Form_IsDirty
  mOriginalJson = JSON.stringify(mRecord);
}

// ===========
// Load Fields
// ===========
function Fields_Load() {
  if (mRecord) {
    // General
    C.txtIdentificationTypeId.Text(mRecord.IdentificationTypeId);
    C.chkActive.Value(mRecord.Active);
    C.txtDescription.Text(mRecord.Description);

    C.txtDescriptionShort.Text(mRecord.DescriptionShort);

    C.cboSpecialType.Text(mRecord.SpecialTypeText);
    
    C.chkEncryptDetails.Value(mRecord.EncryptDetails);

    // Data Entry
    C.chkAllowMainDetails.Value(mRecord.AllowMainDetails);
    C.chkDetailsMandatory.Value(mRecord.DetailsMandatory);
    C.txtDetailsToRecord.Text(mRecord.DetailsToRecord);
    C.txtDetailsTooltipText.Text(mRecord.DetailsTooltipText);
    C.chkAllowName.Value(mRecord.AllowName);
    C.chkAllowNamePasteButton.Value(mRecord.AllowNamePaste);
    C.chkAllowDateOfBirth.Value(mRecord.AllowDateOfBirth);
    C.chkAllowDateOfBirthPasteButton.Value(mRecord.AllowDateOfBirthPaste);
    C.chkAllowAddress.Value(mRecord.AllowAddress);
    C.chkAllowReference.Value(mRecord.AllowReference);
    C.chkAllowIssuer.Value(mRecord.AllowIssuer);
    C.chkAllowExpiryDate.Value(mRecord.AllowExpiryDate);
    C.cboDefaultExpiryCycle.Text(mRecord.DefaultExpiryCycle);

    C.cboInformationListIssuer.Text(mRecord.InformationListIssuerId);
    C.cboInformationListReferenceDesignation.Text(mRecord.InformationListReferenceDesignationId);

    // Validation
    C.cboValidationMethod.Text(mRecord.ValidationMethodText);
    C.txtValidationExpression.Text(mRecord.ValidationExpression);
    C.txtValidationWarning.Text(mRecord.ValidationWarning);
  }

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

  // Update Controls

  // Update fields
  Fields_Update();

  // Refresh Tab
  tabDetails_Refresh();
  tabDetails_Resize();
}

// ===========
// Save Fields
// ===========
function Fields_Save() {
  // General
  mRecord.IdentificationTypeId = C.txtIdentificationTypeId.Text();
  mRecord.Active = C.chkActive.Value();
  mRecord.Description = C.txtDescription.Text();

  mRecord.DescriptionShort = C.txtDescriptionShort.Text();

  mRecord.SpecialTypeText = C.cboSpecialType.Text();
  
  mRecord.EncryptDetails = C.chkEncryptDetails.Value();

  // Data Entry
  mRecord.AllowMainDetails = C.chkAllowMainDetails.Value();
  mRecord.DetailsMandatory = C.chkDetailsMandatory.Value();
  mRecord.DetailsToRecord = C.txtDetailsToRecord.Text();
  mRecord.DetailsTooltipText = C.txtDetailsTooltipText.Text();
  mRecord.AllowName = C.chkAllowName.Value();
  mRecord.AllowNamePaste = C.chkAllowNamePasteButton.Value();
  mRecord.AllowDateOfBirth = C.chkAllowDateOfBirth.Value();
  mRecord.AllowDateOfBirthPaste = C.chkAllowDateOfBirthPasteButton.Value();
  mRecord.AllowAddress = C.chkAllowAddress.Value();
  mRecord.AllowReference = C.chkAllowReference.Value();
  mRecord.AllowIssuer = C.chkAllowIssuer.Value();
  mRecord.AllowExpiryDate = C.chkAllowExpiryDate.Value();
  mRecord.DefaultExpiryCycle = C.cboDefaultExpiryCycle.Text();

  mRecord.InformationListIssuerId = C.cboInformationListIssuer.Text();
  mRecord.InformationListReferenceDesignationId = C.cboInformationListReferenceDesignation.Text();

  // Validation
  mRecord.ValidationMethodText = C.cboValidationMethod.Text();
  mRecord.ValidationExpression = C.txtValidationExpression.Text();
  mRecord.ValidationWarning = C.txtValidationWarning.Text();
}

// =============
// Update Fields
// =============
function Fields_Update() {
  // Heading
  if (mRecord) {
    if (mRecord.IdentificationTypeId) {
      widget.SetHeading("Identification Type (" + mRecord.IdentificationTypeId + ")");
    }
    else {
      widget.SetHeading("New Identification Type");
    }
  }

  // Lists
  if (mRecord) {
    // General
    C.cboSpecialType.ListFromCollection(mRecord.SpecialTypeList, "Description");

    // Data Entry
    C.cboDefaultExpiryCycle.ListFromCsvString("1 Week,1 Month,3 Months,6 Months,1 Year,2 Years,3 Years,4 Years,5 Years,10 Years");
    C.cboInformationListIssuer.RefreshFromStandardRange("InformationLists");
    C.cboInformationListReferenceDesignation.RefreshFromStandardRange("InformationLists");

    // Validation
    C.cboValidationMethod.ListFromCollection(mRecord.ValidationMethodList, "Description");
  }

  // Controls
  if (mRecord) {
    // General
  }

  // Pages
  if (mRecord) {
    // NOTE: Even though many pages are updated in tabDetails_Refresh, we must update them here to ensure controls are hidden since this is not a wizard and all pages are validated on "Finish"
    pageGeneral_Refresh();
    pageDataEntry_Refresh();
    pageValidation_Refresh();
  }

  // Read-Only?
  if (mRecord &amp;&amp; mRecord.ReadOnly) {
    cmdFinish.prop("disabled", true);
    frmMain.FormReadOnly(C, true);
  }

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

  // Resize Tab
  tabDetails_Resize();
}

// ===========
// Resize Form
// ===========
function Form_Resize() {
  // Mobile Optimisations
  var el = $(".mobile-indent th.indent1, .mobile-indent th.no-indent1");
  if (window.innerWidth &lt; 500) {
    el.addClass("no-indent1").removeClass("indent1");
  }
  else {
    el.addClass("indent1").removeClass("no-indent1");
  }

  // General

  // Tab
  tabDetails_Resize();
}

// ========
// Is Dirty
// ========
function Form_IsDirty() {
  if (mRecord) {
    // Save Fields
    Fields_Save();

    // Is Dirty?
    return mOriginalJson != JSON.stringify(mRecord);
  }
  else {
    return false;
  }
}

// ==============
// Wizard Buttons
// ==============
function tabDetails_Cancel() {
  if (Form_IsDirty()) {
    // Confirm
    widget.UI.MsgBoxConfirm("Are you sure you want to close this form without saving your changes?", { heading: "Close Form" }, tabDetails_Cancel_Finalise);
  }
  else {
    // Cancel immediately
    tabDetails_Cancel_Finalise();
  }
}

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

// ==========
// Resize Tab
// ==========
function tabDetails_Resize() {
  switch (tabDetails.SelectedTabId()) {
    case "General":
      // General
      C.txtDescription.WidthResizeFromParent();
      C.txtDescriptionShort.WidthResizeFromParent();
      break;

    case "DataEntry":
      // Data Entry
      break;

    case "Validation":
      // Validation
      C.txtValidationExpression.WidthResizeFromParent();
      C.txtValidationWarning.WidthResizeFromParent();
      break;
  }
}

// ===========
// Refresh Tab
// ===========
function tabDetails_Refresh() {
   // Load details
  switch (tabDetails.SelectedTabId()) {
    case "General":
      pageGeneral_Refresh();
      break;

    case "DataEntry":
      pageDataEntry_Refresh();
      break;

    case "Validation":
      pageValidation_Refresh();
      break;

    default:
      break;
  }

  // Resize
  tabDetails_Resize();

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

// =================
// Execute an Action
// =================
function Form_ExecuteAction(actionId, data) {
  switch(actionId) {
    default:
      window.alert("Unhandled action '" + actionId + "'");
  }
}

// =============
// Finish Action
// =============
function Form_ExecuteAction_Finish() {
  // Assume Success
  var Ok = true;

  // Validate
  Ok = tabDetails.Validate();

  // Prompt
  if (Ok) {
    if (mRecord.PromptOnSave) {
      // Confirm
      widget.UI.MsgBoxConfirm("Are you sure you want to save this record?",
                              { heading: "Save" },
                              Form_ExecuteAction_FinishPost);

    }
    else {
      // Save without prompting
      Form_ExecuteAction_FinishPost();
    }
  }
}

function Form_ExecuteAction_FinishPost() {
  // Disable Form
  widget.UI.Block("Saving, please wait...");

  // Create Parameters
  // NOTE: We will simply update mRecord, clone this and send back (less some information)
  Fields_Save();
  var params = JSON.parse(JSON.stringify(mRecord));
  //params.GendersList = null;

  // Finish
  widget.GetString("Finish", params,
    function (data) {
      // Close Form
      widget.Close();

      // Refresh Parent (to show updated details)
      // NOTE: Pass in Record Id just in case this has changed
      widget.RefreshParent(C.txtIdentificationTypeId.Text());
    },

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

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

// ===========
// pageGeneral
// ===========
function pageGeneral_Refresh() {
  if (!mRecord) return;

  // Controls
  chkEncryptDetails_Change();
}

// =============
// pageDataEntry
// =============
function pageDataEntry_Refresh() {
  if (!mRecord) return;

  // Get Special Type
  var SpecialType = "None";
  if (C.cboSpecialType.ListIndex() != -1) SpecialType = mRecord.SpecialTypeList[C.cboSpecialType.ListIndex()].Code;

  // Controls
  switch (SpecialType) {
    case "None":
      C.chkAllowMainDetails.VisibleRow(true);
      C.chkDetailsMandatory.VisibleRow(C.chkAllowMainDetails.Value());
      C.txtDetailsToRecord.VisibleRow(C.chkAllowMainDetails.Value());
      C.thDetailsTooltipText.addClass("indent1");
      C.txtDetailsTooltipText.VisibleRow(C.chkAllowMainDetails.Value());
      C.chkAllowName.VisibleRow(true);
      C.chkAllowNamePasteButton.WrapperElement().parent().addClass("indent1");
      C.chkAllowNamePasteButton.VisibleRow(C.chkAllowName.Value());
      C.chkAllowDateOfBirth.VisibleRow(true);
      C.chkAllowDateOfBirthPasteButton.WrapperElement().parent().addClass("indent1");
      C.chkAllowDateOfBirthPasteButton.VisibleRow(C.chkAllowDateOfBirth.Value());
      C.chkAllowAddress.VisibleRow(true);
      C.chkAllowReference.VisibleRow(true);
      C.chkAllowIssuer.VisibleRow(true);
      C.chkAllowExpiryDate.VisibleRow(true);
      C.cboDefaultExpiryCycle.VisibleRow(C.chkAllowExpiryDate.Value());

      C.lblInformationLists.VisibleRow(true);
      C.cboInformationListIssuer.VisibleRow(true);
      C.cboInformationListReferenceDesignation.VisibleRow(true);
      break;

    case "AU_Medicare":
      C.chkAllowMainDetails.VisibleRow(false);
      C.chkDetailsMandatory.VisibleRow(false);
      C.txtDetailsToRecord.VisibleRow(false);
      C.thDetailsTooltipText.removeClass("indent1");
      C.txtDetailsTooltipText.VisibleRow(true);
      C.chkAllowName.VisibleRow(false);
      C.chkAllowNamePasteButton.VisibleRow(false);
      C.chkAllowDateOfBirth.VisibleRow(false);
      C.chkAllowDateOfBirthPasteButton.VisibleRow(false);
      C.chkAllowAddress.VisibleRow(false);
      C.chkAllowReference.VisibleRow(false);
      C.chkAllowIssuer.VisibleRow(false);
      C.chkAllowExpiryDate.VisibleRow(false);
      C.cboDefaultExpiryCycle.VisibleRow(false);

      C.lblInformationLists.VisibleRow(false);
      C.cboInformationListIssuer.VisibleRow(false);
      C.cboInformationListReferenceDesignation.VisibleRow(false);
      break;

    default:
      C.chkAllowMainDetails.VisibleRow(false);
      C.chkDetailsMandatory.VisibleRow(false);
      C.txtDetailsToRecord.VisibleRow(false);
      C.thDetailsTooltipText.removeClass("indent1");
      C.txtDetailsTooltipText.VisibleRow(true);
      C.chkAllowName.VisibleRow(false);
      C.chkAllowNamePasteButton.VisibleRow(true);
      C.chkAllowDateOfBirth.VisibleRow(false);
      C.chkAllowDateOfBirthPasteButton.VisibleRow(true);
      C.chkAllowAddress.VisibleRow(false);
      C.chkAllowReference.VisibleRow(false);
      C.chkAllowIssuer.VisibleRow(false);
      C.chkAllowExpiryDate.VisibleRow(false);
      C.cboDefaultExpiryCycle.VisibleRow(false);

      C.lblInformationLists.VisibleRow(false);
      C.cboInformationListIssuer.VisibleRow(false);
      C.cboInformationListReferenceDesignation.VisibleRow(false);
      break;
  }
}

// ==============
// pageValidation
// ==============
function pageValidation_Refresh() {
  if (!mRecord) return;

  // Get Validation Method
  var ValidationMethod = "None";
  if (C.cboValidationMethod.ListIndex() != -1) ValidationMethod = mRecord.ValidationMethodList[C.cboValidationMethod.ListIndex()].Code;
  
  // Get Special Type
  var SpecialType = "None";
  if (C.cboSpecialType.ListIndex() != -1) SpecialType = mRecord.SpecialTypeList[C.cboSpecialType.ListIndex()].Code;

  // Controls
  if (SpecialType == "None") {
    C.lblValidationMethod.VisibleRow(true);
    C.cboValidationMethod.VisibleRow(true);
  
    switch (ValidationMethod) {
      case "Expression":
        C.lblValidationExpression.VisibleRow(true);
        C.txtValidationExpression.VisibleRow(true);
        C.lblValidationWarning.VisibleRow(true);
        C.txtValidationWarning.VisibleRow(true);
        break;

      case "None":
        C.lblValidationExpression.VisibleRow(false);
        C.txtValidationExpression.VisibleRow(false);
        C.lblValidationWarning.VisibleRow(false);
        C.txtValidationWarning.VisibleRow(false);
        break;

      case "RegularExpression":
        C.lblValidationExpression.VisibleRow(true);
        C.txtValidationExpression.VisibleRow(true);
        C.lblValidationWarning.VisibleRow(true);
        C.txtValidationWarning.VisibleRow(true);
        break;

      default:
        C.lblValidationExpression.VisibleRow(false);
        C.txtValidationExpression.VisibleRow(false);
        C.lblValidationWarning.VisibleRow(false);
        C.txtValidationWarning.VisibleRow(false);
        break;
    }
  }
  else {
    C.lblValidationMethod.VisibleRow(false);
    C.cboValidationMethod.VisibleRow(false);
    C.lblValidationExpression.VisibleRow(false);
    C.txtValidationExpression.VisibleRow(false);
    C.lblValidationWarning.VisibleRow(false);
    C.txtValidationWarning.VisibleRow(false);
  }
}

// ==============
// cboSpecialType
// ==============
function cboSpecialType_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  // Refresh pages
  pageDataEntry_Refresh();
  pageValidation_Refresh();
}

// ===================
// cboValidationMethod
// ===================
function cboValidationMethod_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  // Refresh pages
  pageValidation_Refresh();
}

// =================
// chkEncryptDetails
// =================
function chkEncryptDetails_Change(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;
  
  var action = "Encrypt"
  if (!C.chkEncryptDetails.Value()) {
    action = "Decrypt"
  }
  C.divEncryptMessage.html("The option to " + action + " now can be found on the General page of the read-only version of this form in finPOWER Connect Cloud.");
}

// ====================
// Notification Handler
// ====================
function Widget_NotificationHandler(actionId, data) {
   switch(actionId) {
     case "FormClose":
      // Form Close button is disabled so act as if 'Cancel' has been clicked
      tabDetails_Cancel();
      break;
   }
}
&lt;/script&gt;</TemplateText>
    <TemplateTextBookmarks />
    <TimeoutSeconds>60</TimeoutSeconds>
    <UniqueId>64xSjUrdLUiROtN+bLwnqQ</UniqueId>
    <AllowRefresh>true</AllowRefresh>
    <Caption>Identification Type</Caption>
    <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>
    <Icon>IdentificationType</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 />
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="HideOtherPages" type="Boolean">
            <BlankTip />
            <Caption>Hide pages other than the one being edited?</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value>True</Value>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="" type="SectionStart">
            <BlankTip />
            <Caption>Configuration options.</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="" type="SectionStart">
            <BlankTip />
            <Caption>TESTING</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="IdentificationTypeId" type="Range">
            <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>
            <LimitToList>false</LimitToList>
            <MaxLength>10</MaxLength>
            <RangeSingle>true</RangeSingle>
            <RangeType>Standard</RangeType>
            <RangeLookupSource>IdentificationTypes</RangeLookupSource>
            <RangeLookupSqlWhere />
          </Parameter>
          <Parameter name="DuplicateRecordId" 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.IdentificationTypes</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="Page" 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>General,Data Entry,Validation</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="ReadOnly" type="Boolean">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value>False</Value>
            <Visible>true</Visible>
          </Parameter>
        </Parameters>
      </ISParameterDefs>
    </Parameters>
  </finScript>