<?xml version="1.0" encoding="utf-8"?>
  <finScript version="1.00" exportedUtcDate="2023-03-20T01:30:15.0000000">
    <CreatedUserId>Admin</CreatedUserId>
    <CreatedUtcDate>2019-10-22T22:20:04.4250000</CreatedUtcDate>
    <UpdatedUserId>Admin</UpdatedUserId>
    <UpdatedUtcDate>2023-03-20T01:26:52.4120000</UpdatedUtcDate>
    <ScriptId>CBAC</ScriptId>
    <Description>Client Bank Account Change</Description>
    <ScriptType>HtmlWidget</ScriptType>
    <Active>true</Active>
    <AllowUI>false</AllowUI>
    <Bookmarks />
    <Category />
    <Code>' HtmlWidget_ClientBankAccountChange
Option Explicit On
Option Strict On

' #################################################################
' Client Bank Account Change
'
' Version: 1.03 (20/03/2023)
'
' Usage: System-defined HTML Widget
' #################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.03  20/03/2023  ISS      J030712   Visual glitch when first loaded
' #################################################################

' Constants
Private Const FORM_KEY As String = "ClientBankAccountChange"

' Common Parameters
Private mClientBankAccountPk As Integer
Private mClientId As String

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

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

  ' Assume Success
  Main = True

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

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

  ' Get Common Parameters
  With mCombinedParameters
    mClientId = .GetString("ClientId")
    mClientBankAccountPk = .GetInteger("ClientBankAccountPk")
  End With

  ' Handle Events
  Select Case eventId
    Case ""
      returnValue = ScriptInfo.TemplateText

    Case "GetInitialisationInfo"
      Main = GetInitialisationInfo(returnValue)

    Case "Finish"
      Main = Finish(parametersJson)

    Case "GetAccountPreview"
      Main = GetAccountPreview(returnValue)

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

End Function

''' &lt;summary&gt;
'''  Creates a loaded finClientBankAccountChange for this Client and Bank Account.
''' &lt;/summary&gt;
Private Function CreateClientBankAccountChange(ByRef clientBankAccountChange As finClientBankAccountChange) As Boolean

  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise ByRef Parameters
  clientBankAccountChange = finBL.CreateClientBankAccountChange()

  ' Load
  Success = clientBankAccountChange.Load(mClientId, mClientBankAccountPk)

  Return Success

End Function

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

  Dim ScriptContextData As ISKeyValueList

  ' Initialise
  ScriptContextData = finBL.CreateKeyValueList()

  With ScriptContextData
    .SetObject("Target", ScriptInfo.Target)
    .SetBoolean("HighDpi", finBL.HighDpi)
    .SetString("FormKey", FORM_KEY)
    .SetString("FormRecordMode", iseFormRecordMode.Loaded.ToString())
  End With

  Return ScriptContextData

End Function

''' &lt;summary&gt;
'''  Commits Client Bank Account Change.
''' &lt;/summary&gt;
Private Function Finish(parametersJson As String) As Boolean

  Dim ClientBankAccountChange As finClientBankAccountChange
  Dim ClientBankAccountChangeAccount As finClientBankAccountChangeAccount
  Dim obj As Object
  Dim Success As Boolean
  Dim WizardFinishParameters As WizardFinishParameters

  ' Assume Success
  Success = True

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

  ' Create Object
  If Success Then
    Success = CreateClientBankAccountChange(ClientBankAccountChange)
  End If

  ' Flag selected items for update
  If Success Then
    For Each ClientBankAccountChangeAccount In ClientBankAccountChange.Accounts
      With ClientBankAccountChangeAccount
        .Include = WizardFinishParameters.Exists(.AccountPk, .BankingSourceFriendlyName)
      End With
    Next
  End If

  ' Execute
  If Success Then
    Success = ClientBankAccountChange.ExecuteCommit()
  End If

  Return Success

End Function

''' &lt;summary&gt;
'''  Get the HTML Summary Page for the active row on the grid.
''' &lt;/summary&gt;
Private Function GetAccountPreview(ByRef returnValue As String) As Boolean

  Dim AccountPk As Integer
  Dim Success As Boolean

  ' Assume Success
  Success = True

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

  ' Create Response
  If Success Then
    returnValue = finBL.SummaryPageFunctions.AccountSummary(False, AccountPk, Me.CreateScriptContextData())
  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 ClientBankAccountChange As finClientBankAccountChange
  Dim ClientBankAccountChangeAccount As finClientBankAccountChangeAccount
  Dim FormInitialisationInfo As FormInitialisationInfo
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate
  If Len(mClientId) = 0 Then
    Success = False
    finBL.Error.ErrorBegin("Client Id not specified.")
  ElseIf mClientBankAccountPk = 0 Then
    Success = False
    finBL.Error.ErrorBegin("Client Bank Account Pk not specified.")
  ElseIf finBL.CurrentUserInformation.IsClientFilteredOut(mClientId) Then
    Success = False
    finBL.Error.ErrorBegin("You do not have permission to view this record.")
  ElseIf mClientBankAccountPk &lt; 0 Then
    Success = False
    finBL.Error.ErrorBeginFormat("Invalid Client Bank Account Pk {0}.", mClientBankAccountPk)
  End If

  ' Create Client Bank Account Change Object
  If Success Then
    Success = CreateClientBankAccountChange(ClientBankAccountChange)
  End If

  ' Get Initialisation Info
  If Success Then
    FormInitialisationInfo = New FormInitialisationInfo()
    With FormInitialisationInfo
      .ReadOnly = finBL.Database.IsReadOnly

      ' Accounts
      For Each ClientBankAccountChangeAccount In ClientBankAccountChange.Accounts
        .ClientBankAccountChangeAccounts.Add(New ClientBankAccountChangeAccount(ClientBankAccountChangeAccount))
      Next

      ' Other Configuration
      .PromptOnCommit = finBL.CloudConnectFunctions.CloudConnectSettings.PromptOnCommit
    End With
  End If

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

  Return Success

End Function

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

  Public [ReadOnly] As Boolean
  Public ClientBankAccountChangeAccounts As New List(Of ClientBankAccountChangeAccount)

' Configuration
  Public PromptOnCommit As Boolean

End Class

''' &lt;summary&gt;
'''  Client Bank Account Change Account.
''' &lt;/summary&gt;
Public Class ClientBankAccountChangeAccount

  Public AccountId As String
  Public AccountPk As Integer
  Public AccountTypeId As String
  Public BankAccountName As String
  Public BankAccountNumber As String
  Public BankingPaymentTypeClassText As String
  Public BankingSourceFriendlyName As String
  Public CanInclude As Boolean
  Public Name As String

  Public Sub New(clientBankAccountChangeAccount As finClientBankAccountChangeAccount)

    With clientBankAccountChangeAccount
      Me.AccountId = .AccountId
      Me.AccountPk = .AccountPk
      Me.AccountTypeId = .AccountTypeId

      With .BankingDetails
        Me.BankAccountName = .AccountName
        Me.BankAccountNumber = .AccountNumber
      End With

      Me.BankingPaymentTypeClassText = .BankingDetails.PaymentTypeClassText
      Me.BankingSourceFriendlyName = .BankingSourceFriendlyName
      Me.CanInclude = .CanInclude
      Me.Name = .Name
    End With

  End Sub

End Class

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

  Public RecordsToUpdate As New List(Of RecordToUpdate)

  ''' &lt;summary&gt;
	'''  Returns True if a specific accountPk and source combination exist in the collection.
	''' &lt;/summary&gt;
  Public Function Exists(accountPk As Integer,
                         source As String) As Boolean

    Dim RecordToUpdate As RecordToUpdate

    For Each RecordToUpdate In Me.RecordsToUpdate
      With RecordToUpdate
        If .AccountPk = accountPk AndAlso .Source = source Then
          Return True
        End If
      End With
    Next

    Return False

  End Function

End Class

Public Class RecordToUpdate

  Public AccountPk As Integer
  Public Source As String

End Class</Code>
    <Language>VisualBasic</Language>
    <Notes>System-supplied HTML Widget to bulk apply Client Bank Accounts to Accounts.</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="General" tooltipText="Select the Accounts to update."&gt;Accounts&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;div class="is-dock-fill is-split-container split5050"&gt;
        &lt;div class="panel"&gt;
          &lt;div id="gridAccounts"&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="panel"&gt;
          &lt;div id="wbAccounts" class="is-dock-fill"&gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;

  &lt;!-- Form Footer --&gt;
  &lt;footer&gt;
    &lt;button id="cmdCancel" class="is-button"&gt;Cancel&lt;/button&gt;
    &lt;button id="cmdFinish" class="is-button ok"&gt;OK&lt;/button&gt;
  &lt;/footer&gt;
&lt;/div&gt;

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

// Controls
var C = {
  gridAccounts: null,
  wbAccounts: null
}

// Form
var frmMain;
var tabWizard;

// Wizard Buttons
var cmdCancel;
var cmdFinish;

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

  // Controls
  C.wbAccounts = widget.UI.PreviewPane("wbAccounts", {});

  // Grids
  C.gridAccounts = widget.UI.Grid("gridAccounts", {
    allowMultiRowSelect: true,
    docked: true,
    showRowSelectors: true,
    stickyHeader: true,

    onAction: gridAccounts_Action,
    onAfterRowActivate: gridAccounts_AfterRowActivate,
    onBeforeCellUpdate: gridAccounts_BeforeCellUpdate,
    onInitialiseRow: gridAccounts_InitialiseRow
  });

  // 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");
  cmdFinish = $("#cmdFinish");
  cmdCancel.click(tabWizard_Cancel);
  cmdFinish.click(function() { Form_ExecuteAction("Finish"); });

  // Reset
  Form_Reset();
});

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

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

  // Resize
  Form_Resize();

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

// ===========
// Record Load
// ===========
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
    function (data) {
      mRecord = JSON.parse(data);
      Fields_Load();
    },

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

// ===========
// Fields Load
// ===========
function Fields_Load() {
  if (mRecord) {
    // General
  }

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

  // Update Controls

  // Update fields
  Fields_Update();

  // Refresh Tab
  tabWizard_Refresh();
}

// =============
// Fields Update
// =============
function Fields_Update() {
  // Information Lists

  // Lists

  // Controls

  // Update Buttons
  tabWizard_UpdateButtons();

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

  // Resize Tab
  tabWizard_Resize();
}

// ========================
// Create Finish Parameters
// ========================
function CreateFinishParameters() {
  var records = [];

  // Identify which Accounts are being included
  for(var i = 0; i &lt; mRecord.ClientBankAccountChangeAccounts.length; i++) {
    var item = mRecord.ClientBankAccountChangeAccounts[i];

    if(item.Include &amp;&amp; item.CanInclude) {
      var o = {
        accountPk: item.AccountPk,
        source: item.BankingSourceFriendlyName
      }
      records.push(o);
    }
  }

  return { recordsToUpdate: records };
}

// =================
// Execute an Action
// =================
function Form_ExecuteAction(actionId) {
  switch (actionId.toUpperCase()) {
    case "FINISH":
      // Finish
      if (mRecord.ReadOnly) {
        tabWizard_Cancel();
      }
      else {
        Form_ExecuteAction_Finish();
      }
      break;

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

// =============
// Finish Action
// =============
function Form_ExecuteAction_Finish() {
  // Validate
  tabWizard_Validate(function() {
    if (mRecord.PromptOnCommit) {
      // Confirm
      var heading = "Update Bank Account Details";
      var message = "Are you sure you want to update Bank Account details on the selected Accounts?";

      widget.UI.MsgBoxConfirm(message,
                              {
                                heading: heading,
                              },
                              Form_ExecuteAction_FinishPost,
                              null);
    }
    else {
      // Commit without prompting
      Form_ExecuteAction_FinishPost();
    }
  });
}

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

  // Get Parameters
  var params = CreateFinishParameters();

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

      // Refresh Parent
      widget.RefreshParent();
    },

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

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

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

  // Tab
  tabWizard_Resize();
}

// ============
// gridAccounts
// ============
function gridAccounts_Action(actionId) {
  switch (actionId.toUpperCase()) {
    case "REFRESH":
      Record_Load();
      break;

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

      for(var i = 0; i &lt; mRecord.ClientBankAccountChangeAccounts.length; i++) {
        if(mRecord.ClientBankAccountChangeAccounts[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; mRecord.ClientBankAccountChangeAccounts.length; i++) {
        var item = mRecord.ClientBankAccountChangeAccounts[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; mRecord.ClientBankAccountChangeAccounts.length; i++) {
        var item = mRecord.ClientBankAccountChangeAccounts[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 "SELECTSAME":
      var activeRowIndex = C.gridAccounts.ActiveDataRowListIndex();
      var selectedItem = mRecord.ClientBankAccountChangeAccounts[activeRowIndex];
      var indexes = [];

      for(var i = 0; i &lt; mRecord.ClientBankAccountChangeAccounts.length; i++) {
        var item = mRecord.ClientBankAccountChangeAccounts[i];
        if(item.BankAccountNumber == selectedItem.BankAccountNumber) indexes.push(i);
      }
      break;

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

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

    default:
      break;
  }

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

function gridAccounts_AfterRowActivate(e) {
  // Preview
  wbAccounts_Preview();
}

function gridAccounts_BeforeCellUpdate(e) {
  var item = mRecord.ClientBankAccountChangeAccounts[e.row.listIndex];

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

function gridAccounts_InitialiseRow(e) {
  var item = mRecord.ClientBankAccountChangeAccounts[e.row.listIndex];

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

  // Set Icon
  e.row.cells.Icon.value = "Blank";

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

  // Cell hyperlinks
  if(item.AccountId) {
    e.row.cells.AccountId.hyperlink = "app://formshow?form=Account&amp;id=" + encodeURI(item.AccountId);
  }
}

function gridAccounts_Refresh() {
  // Add Columns
  C.gridAccounts.ClearColumns();
  C.gridAccounts.AddColumnIcon("Icon", { caption: ""});
  C.gridAccounts.AddColumnBoolean("Include", { caption: "Include", allowEdit: true });
  C.gridAccounts.AddColumnString("AccountTypeId", { caption: "Type" });
  C.gridAccounts.AddColumnCode("AccountId", { caption: "Account" });
  C.gridAccounts.AddColumnString("Name", { caption: "Name" });
  C.gridAccounts.AddColumnString("BankingSourceFriendlyName", { caption: "Source" });
  C.gridAccounts.AddColumnString("BankingPaymentTypeClassText", { caption: "Type" });
  C.gridAccounts.AddColumnString("BankAccountNumber", { caption: "Number" });
  C.gridAccounts.AddColumnString("BankAccountName", { caption: "Name" });

  // Actions
  C.gridAccounts.Actions().Define([{ actionId: "Refresh", tooltipText:"Refresh list", 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", caption: "Included", tooltipText: "Select all rows that are checked to include", icon: "Select_Checked" },
                                   { actionId: "SelectUnchecked", caption: "Excluded", tooltipText: "Select all rows that are not checked to include", icon: "Select_Unchecked" },
                                   { actionId: "SelectSame", caption: "Same Bank Account", tooltipText: "Select all rows with the same Bank Account Number", icon: "Select_Same" },
                                   {},
                                   { actionId: "Check", tooltipText: "Check selected row(s)", icon: "Checkbox_Checked" },
                                   { actionId: "Uncheck", tooltipText: "Uncheck selected row(s)", icon: "Checkbox_Unchecked" }
                                  ]);

  // Give collection ability to form a unique cache key and preview parameters for the Widget
  // NOTE: Because this is just an Account Summary, it doesn't matter if several rows share the same cache key
  mRecord.ClientBankAccountChangeAccounts.GetCacheKey = function (index) {
    var item = mRecord.ClientBankAccountChangeAccounts[index];
    return item.AccountPk;
  };
  mRecord.ClientBankAccountChangeAccounts.GetPreviewFetchParameters = function (index) {
    var item = mRecord.ClientBankAccountChangeAccounts[index];
    var o = {};

    o.accountPk = item.AccountPk;
    o.target = "WebInternal";
    o.highDpi = widget.IsHighDpi();

    return o;
  };

  // Refresh
  C.gridAccounts.VirtualDataRefresh(mRecord.ClientBankAccountChangeAccounts);

  // Activate First Row
  C.gridAccounts.ActivateFirstDataRow();
}

// ==========
// wbAccounts
// ==========
function wbAccounts_Preview() {
  C.wbAccounts.PreviewFromGridCollection(C.gridAccounts, mRecord.ClientBankAccountChangeAccounts, "GetAccountPreview");
}


// =================
// Tab Wizard Cancel
// =================
function tabWizard_Cancel() {
  if (widget.CanClose()) {
    widget.Close();
  }
  else {
    widget.Reset();
  }
}

// ==================
// Tab Wizard Refresh
// ==================
function tabWizard_Refresh(newTab) {
  // Moving forward onto tab, so Load information
  if (newTab &gt;= tabWizard.SelectedTabIndex()) {
    switch (tabWizard.GetTabIdByIndex(newTab)) {
      default:
        break;
    }
  }

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

  // Special
  switch(tabWizard.SelectedTabId()) {
    case "General":
      gridAccounts_Refresh();
      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;
  }
}

// =================
// Tab Wizard Resize
// =================
function tabWizard_Resize() {
  switch (tabWizard.SelectedTabId()) {
    default:
      break;
  }
}

// =========================
// Tab Wizard Update Buttons
// =========================
function tabWizard_UpdateButtons() {
  // Back and Next Buttons?
  if(mRecord) {
    cmdFinish.prop("disabled", mRecord.ReadOnly);
  }

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

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

  // Other client-side validation
  if (Ok) {
    switch (tabWizard.SelectedTabId()) {
      case "General":
        var found = false;

        // At least one row must be selected for update.
        for(var i = 0; i &lt; mRecord.ClientBankAccountChangeAccounts.length; i++) {
          if(mRecord.ClientBankAccountChangeAccounts[i].Include) {
            found = true;
            break;
          }
        }

        if(!found) {
          Ok = false;
          widget.UI.MsgBoxAlert("You have not selected any items to include.");
        }
        break;

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

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

    switch (tabWizard.SelectedTabId()) {
      case "General":
        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();
    }
  }
}
&lt;/script&gt;</TemplateText>
    <TemplateTextBookmarks />
    <TimeoutSeconds>60</TimeoutSeconds>
    <UniqueId>wYYphgN+L0mAx1avTFCqLQ</UniqueId>
    <AllowRefresh>true</AllowRefresh>
    <Caption />
    <HtmlWidgetMaxHeight>1024</HtmlWidgetMaxHeight>
    <HtmlWidgetMaxWidth>1200</HtmlWidgetMaxWidth>
    <HtmlWidgetNeverApplyStyling>false</HtmlWidgetNeverApplyStyling>
    <HtmlWidgetResourceChartsApex>false</HtmlWidgetResourceChartsApex>
    <HtmlWidgetResourceCssSummaryPage2>false</HtmlWidgetResourceCssSummaryPage2>
    <HtmlWidgetResourceCssWidget>true</HtmlWidgetResourceCssWidget>
    <HtmlWidgetResourceJQuery>true</HtmlWidgetResourceJQuery>
    <HtmlWidgetResourceJQueryVersion />
    <HtmlWidgetSpecialEventGetFolderCount>false</HtmlWidgetSpecialEventGetFolderCount>
    <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 />
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="ClientId" type="List">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <List>RANGE.Clients</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="ClientBankAccountPk" type="Number">
            <BlankTip />
            <Caption />
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <DefaultValueExpression />
            <Enabled>true</Enabled>
            <HideDescription>false</HideDescription>
            <IndentLevel>0</IndentLevel>
            <Mandatory>false</Mandatory>
            <NonPersistable>false</NonPersistable>
            <ReadOnly>false</ReadOnly>
            <ReadOnly2>false</ReadOnly2>
            <Value />
            <Visible>true</Visible>
            <DecimalPlaces>0</DecimalPlaces>
            <GroupDigits>true</GroupDigits>
            <MaxValue />
            <MinValue />
            <NumberSpecialType>None</NumberSpecialType>
            <SpinChange>1</SpinChange>
          </Parameter>
        </Parameters>
      </ISParameterDefs>
    </Parameters>
  </finScript>