<?xml version="1.0" encoding="utf-8"?><finScript version="1.00" exportedUtcDate="2021-12-07T21:44:13.0000000"><CreatedUserId>Admin</CreatedUserId><CreatedUtcDate>2021-12-01T01:39:28.3290000</CreatedUtcDate><UpdatedUserId>Admin</UpdatedUserId><UpdatedUtcDate>2021-12-07T20:52:37.9770000</UpdatedUtcDate><ScriptId>LSE</ScriptId><Description>Log Severity Edit</Description><ScriptType>HtmlWidget</ScriptType><Active>true</Active><AllowUI>false</AllowUI><Category /><Code>' HtmlWidget_LogSeverityEdit
Option Explicit On
Option Strict On

' #################################################################
' Log Severity Edit form HTML Widget
'
' Version: 1.00 (08/12/2021)
'
' Usage: System-supplied HTML Widget
' #################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.00  08/12/2021  ISS      J027928   Created
' #################################################################

' Constants
Private Const FORM_KEY As String = "LogSeverities"

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

' Standard Parameters
Private mLogSeverityId 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
    mLogSeverityId = .GetString("LogSeverityId") ' Always use Startup Parameters since the Log Severity 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 Log Severity.
''' &lt;/summary&gt;
Private Function GetLogSeverity(ByRef logSeverity As finLogSeverity) As Boolean

  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate

  ' Create and Load Log Severity
  If Success Then
    ' Create Log Severity
    logSeverity = finBL.CreateLogSeverity()

    ' Load Log Severity
    If Len(mDuplicateRecordId) &lt;&gt; 0 Then
      ' New record (by duplicating existing)
      Success = logSeverity.Load(mDuplicateRecordId)
      If Success Then logSeverity.Duplicate()
    ElseIf Len(mLogSeverityId) = 0 Then
      ' New record
    Else
      Success = logSeverity.Load(mLogSeverityId)
    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 LogSeverity As finLogSeverity
  Dim FormInitialisationInfo As FormInitialisationInfo
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate

  ' Get Log Severity
  If Success Then
    Success = GetLogSeverity(LogSeverity)
  End If

  ' Get Initialisation Info
  If Success Then
    FormInitialisationInfo = New FormInitialisationInfo()
    With FormInitialisationInfo
      ' Form
      .PageId = mPage
      If finBL.Database.IsReadOnly OrElse mReadOnly Then
        .ReadOnly = True
      Else
        .ReadOnly = False
      End If

      ' Record
      .Pk = LogSeverity.Pk
      .Timestamp = LogSeverity.Timestamp

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

      ' General
      .LogSeverityId = LogSeverity.LogSeverityId ' Always need to return Log Severity Id
      If .AllowPageGeneral Then
        .Active = LogSeverity.Active
        .Description = LogSeverity.Description

        .ImportanceText = LogSeverity.ImportanceText

        .OpenColourBackground = LogSeverity.OpenColourBackground
        .OpenColourForeground = LogSeverity.OpenColourForeground

        .CompleteColourBackground = LogSeverity.CompleteColourBackground
        .CompleteColourForeground = LogSeverity.CompleteColourForeground
      End If

      ' Other

      ' Permissions

      ' Lists
      .ImportanceList = finBL.Enums.isefinLogImportance_GetList().ToCsvString()

      ' 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 Log Severity.
''' &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 LogSeverity As finLogSeverity
  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 Log Severity
  If Success Then
    Success = GetLogSeverity(LogSeverity)
  End If

  ' Validate
  If Success Then
    If Record.Timestamp &lt;&gt; LogSeverity.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 Log Severity
      With LogSeverity
        ' General
        If Record.AllowPageGeneral Then
          .LogSeverityId = Record.LogSeverityId
          .Active = Record.Active
          .Description = Record.Description

          .ImportanceText = Record.ImportanceText

          .OpenColourBackground = Record.OpenColourBackground
          .OpenColourForeground = Record.OpenColourForeground

          .CompleteColourBackground = Record.CompleteColourBackground
          .CompleteColourForeground = Record.CompleteColourForeground
        End If
      End With

      ' Save
      If Success Then
        Success = LogSeverity.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 LogSeverityId As String
  Public Active As Boolean
  Public Description As String

  Public ImportanceText As String

  Public OpenColourBackground As String
  Public OpenColourForeground As String

  Public CompleteColourBackground As String
  Public CompleteColourForeground As String

  ' Permissions
  Public AllowPageGeneral As Boolean

  ' Lists
  Public ImportanceList As String

  ' 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 a Log Severity.</Notes><PermissionKeyExecute /><RunWithoutPrompts>false</RunWithoutPrompts><TemplateText>&lt;div id="frmMain" class="is-widget-content" style="visibility:hidden"&gt;

 &lt;style type="text/less"&gt;
   div.colour-preview {
      display:inline-block;
      border:1px solid rgba(0,0,0,0.1);
      height:32px;
      line-height:32px;
      margin:4px 0 0 0;
      padding:0;
      text-align:center;
      width:100px;
   }
 &lt;/style&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;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="txtLogSeverityId"&gt;Code:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="txtLogSeverityId"/&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&gt;Importance&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboImportance"&gt;Importance:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboImportance"/&gt;&lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label&gt;Colours for 'Incomplete' Logs&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboOpenColourForeground"&gt;Foreground:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboOpenColourForeground"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboOpenColourBackground"&gt;Background:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboOpenColourBackground"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;div id="divPreviewOpen" class="colour-preview"&gt;Preview&lt;/div&gt;&lt;/th&gt;
        &lt;/tr&gt;

        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;label&gt;Colours for 'Complete' Logs&lt;/label&gt;&lt;/th&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboCompleteColourForeground"&gt;Foreground:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboCompleteColourForeground"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th&gt;&lt;label for="cboCompleteColourBackground"&gt;Background:&lt;/label&gt;&lt;/th&gt;
          &lt;td&gt;&lt;input id="cboCompleteColourBackground"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;th colspan="2"&gt;&lt;div id="divPreviewComplete" class="colour-preview"&gt;Preview&lt;/div&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,
  txtLogSeverityId: null,
  txtDescription: null,

  cboImportance: null,

  cboOpenColourForeground: null,
  cboOpenColourBackground: null,
  divPreviewOpen: null,

  cboCompleteColourForeground: null,
  cboCompleteColourBackground: null,
  divPreviewComplete: null,
}

// Form
var frmMain;
var tabDetails;

// Buttons
var cmdCancel;
var cmdFinish;

// Other

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

  // --------
  // Controls
  // --------
  //   General
  C.lblCodeAndName = widget.UI.Label("lblCodeAndName", {});
  C.txtLogSeverityId = widget.UI.TextBox("txtLogSeverityId", {
    allowBlank: false,
    maxLength: 5,
    width: widget.UI.FIELD_WIDTH_CODE_5,
  });
  C.chkActive = widget.UI.CheckBox("chkActive", {
    caption: "Active?",
  });
  C.txtDescription = widget.UI.TextBox("txtDescription", {
    allowBlank: false,
    maxLength: 50,
  });

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

  C.cboOpenColourForeground = widget.UI.ColourChooserComboBox("cboOpenColourForeground", {
    width: "12em",

    onChange: divPreview_Refresh,
  });
  C.cboOpenColourBackground = widget.UI.ColourChooserComboBox("cboOpenColourBackground", {
    width: "12em",

    onChange: divPreview_Refresh,
  });
  C.divPreviewOpen = $("#divPreviewOpen");

  C.cboCompleteColourForeground = widget.UI.ColourChooserComboBox("cboCompleteColourForeground", {
    width: "12em",

    onChange: divPreview_Refresh,
  });
  C.cboCompleteColourBackground = widget.UI.ColourChooserComboBox("cboCompleteColourBackground", {
    width: "12em",

    onChange: divPreview_Refresh,
  });
  C.divPreviewComplete = $("#divPreviewComplete");

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

  // 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.txtLogSeverityId.Text(mRecord.LogSeverityId);
    C.chkActive.Value(mRecord.Active);
    C.txtDescription.Text(mRecord.Description);

    C.cboImportance.Text(mRecord.ImportanceText);

    C.cboOpenColourBackground.Text(mRecord.OpenColourBackground);
    C.cboOpenColourForeground.Text(mRecord.OpenColourForeground);

    C.cboCompleteColourBackground.Text(mRecord.CompleteColourBackground);
    C.cboCompleteColourForeground.Text(mRecord.CompleteColourForeground);
  }

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

  // Update Controls

  // Update fields
  Fields_Update();

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

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

  mRecord.ImportanceText = C.cboImportance.Text();

  mRecord.OpenColourBackground = C.cboOpenColourBackground.Text();
  mRecord.OpenColourForeground = C.cboOpenColourForeground.Text();

  mRecord.CompleteColourBackground = C.cboCompleteColourBackground.Text();
  mRecord.CompleteColourForeground = C.cboCompleteColourForeground.Text();
}

// =============
// Update Fields
// =============
function Fields_Update() {
  // Heading
  if (mRecord) {
    if (mRecord.LogSeverityId) {
      widget.SetHeading("Log Severity (" + mRecord.LogSeverityId + ")");
    }
    else {
      widget.SetHeading("New Log Severity");
    }
  }

  // Information Lists
  if (mRecord) {
  }

  // Lists
  if (mRecord) {
    // General
    C.cboImportance.ListFromCsvString(mRecord.ImportanceList);
  }

  // Controls
  if (mRecord) {
  }

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

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

// ===========
// Refresh Tab
// ===========
function tabDetails_Refresh() {
   // Load details
  switch (tabDetails.SelectedTabId()) {
    case "General":
      pageGeneral_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.txtLogSeverityId.Text());
    },

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

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

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

  // Controls
  divPreview_Refresh();
}

// ==========
// divPreview
// ==========
function divPreview_Refresh(sender, e) {
  // Handled
  if (e) e.ChangeHandled = true;

  C.divPreviewOpen.css("color", C.cboOpenColourForeground.Text());
  C.divPreviewOpen.css("background-color", C.cboOpenColourBackground.Text());

  C.divPreviewComplete.css("color", C.cboCompleteColourForeground.Text());
  C.divPreviewComplete.css("background-color", C.cboCompleteColourBackground.Text());
}

// ====================
// 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>hQUaDgext0KhUc6Yr0Li1w</UniqueId><AllowRefresh>true</AllowRefresh><Caption>Log Severity</Caption><HtmlWidgetMaxHeight>800</HtmlWidgetMaxHeight><HtmlWidgetMaxWidth>800</HtmlWidgetMaxWidth><HtmlWidgetNeverApplyStyling>false</HtmlWidgetNeverApplyStyling><HtmlWidgetResourceCssSummaryPage2>false</HtmlWidgetResourceCssSummaryPage2><HtmlWidgetResourceCssWidget>true</HtmlWidgetResourceCssWidget><HtmlWidgetResourceJQuery>true</HtmlWidgetResourceJQuery><HtmlWidgetResourceJQueryVersion /><Icon>LogSeverity</Icon><JavaScriptDebugger>None</JavaScriptDebugger><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="LogSeverityId" 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>LogSeverities</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.ClientTypes</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,Filters</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>