<?xml version="1.0" encoding="utf-8"?>
  <finScript version="1.00" exportedUtcDate="2026-04-07T01:22:47.0000000">
    <CreatedUserId>Admin</CreatedUserId>
    <CreatedUtcDate>2026-03-15T22:45:57.4770000</CreatedUtcDate>
    <UpdatedUserId>Admin</UpdatedUserId>
    <UpdatedUtcDate>2026-04-07T01:20:31.1430000</UpdatedUtcDate>
    <ScriptId>AIRECORDINSIGHTS</ScriptId>
    <Description>AI Record Insights form</Description>
    <ScriptType>HtmlWidget</ScriptType>
    <Active>true</Active>
    <AllowUI>false</AllowUI>
    <Bookmarks />
    <Category />
    <Code>' HtmlWidget_AIRecordInsights
Option Explicit On
Option Strict On

' #################################################################
' AI Record Insights form
'
' (c) Copyright Intersoft Systems Limited 2026
'
' Version: 1.01 (03/06/2026)
'
' Usage: System-defined HTML Widget
' #################################################################
' Version        Date  User     Job       Description
' -------  ---------- -------  --------  -------------------------
'    1.00  07/04/2026  ISS      J036700   Created
'    1.01  03/06/2026  ISS      J036813   Added collapsible Table of Contents to the Source page
' #################################################################

Imports System.Threading.Tasks

' Constants
Private Const FORM_KEY As String = "AIRecordInsights"

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

' Standard Parameters
Private mRecordType As String
Private mRecordId As String

' Options
Private mConversationMode As Boolean = False
Private mDebug As Boolean = True
Private mIncludeBuiltInAutoPrompts As Boolean = True

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)

  ' Other Parameters
  With mCombinedParameters
    mRecordType = .GetString("RecordType")
    mRecordId = .GetString("RecordId")
    
    mConversationMode = .GetBoolean("ConversationMode", mConversationMode)
    mDebug = .GetBoolean("Debug", mDebug)
    mIncludeBuiltInAutoPrompts = .GetBoolean("IncludeBuiltInAutoPrompts", mIncludeBuiltInAutoPrompts)
  End With
  
  ' Handle Events
  Select Case eventId
    Case ""
      ' Main event, i.e., return initial HTML content (excluding html and body tags)
      returnValue = ScriptInfo.TemplateText

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

    Case "GetInsight"
      ' Get Insight
      If True Then
        ' Desktop 
        ' NOTE: Avoid dead-locking Windows Forms
        Dim ResultTask As Task(Of String) = Task.Run(Async Function() As Task(Of String)
                                 Return Await GetInsight()
                              End Function)
    
        returnValue  = ResultTask.Result        
      Else
        ' Web
      End If
      
    Case Else
      finBL.Error.ErrorBeginFormat("Unhandled event '{0}'.", eventId)
      Main = False
  End Select

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 BranchId As String
  Dim CostCentrePk As Integer
  Dim FormInitialisationInfo As FormInitialisationInfo
  Dim InsightsObject As I_finAIQuestionable
  Dim Model As String
  Dim QuestionableText As String
  Dim RecordDescription As String
  Dim RecordTypeDescription As String
  Dim ServiceDetails As String  
  Dim ServiceName As String
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise
  FormInitialisationInfo = New FormInitialisationInfo()
  
  ' Get Questinonable Text
  If Success Then
    If GetObjectForInsights(InsightsObject, RecordDescription, RecordTypeDescription, BranchId) Then
      Success = InsightsObject.GetAISummaryQuestionableText(QuestionableText) 
    Else
      Success = False
    End If
  End If
  
  ' Get Service details
  If Success Then
    If finBL.AI.GetServiceDetailsFromBranch(BranchId, isefinAIServiceUsage.Simple, ServiceName, CostCentrePk, Model) Then
      If finBL.CostCentres.ExistsPk(CostCentrePk) Then
        ServiceDetails = String.Format("{0} ({1}) - Cost Centre '{2}'", ServiceName, Model, finBL.CostCentres.ItemByPk(CostCentrePk).CostCentreId)
      Else
        ServiceDetails = String.Format("{0} ({1})", ServiceName, Model)        
      End If
    Else
      Success = False
    End If
  End If

  ' Get Form Initialisation Info
  If Success Then
    With FormInitialisationInfo
      ' Record
      .RecordType = mRecordType
      .RecordTypeDescription = RecordTypeDescription      
      .RecordId = mRecordId
      
      ' Other
      .BranchId = BranchId
      .QuestionableText = QuestionableText
      .ServiceDetails = ServiceDetails
      
      ' Auto Prompts
      .AutoPromptCollections = GetAutoPromptCollections()
  
      ' Configuration
      .ConversationMode = mConversationMode
      .IsClientManagement = finBL.IsClientManagement ' Internal use only
    End With
  End If
  
  ' Serialise
  If Success Then
    Success = finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(FormInitialisationInfo, returnValue)
  End If

  Return Success

End Function

Private Function GetAutoPromptCollections() As List(Of AutoPromptCollection)
  
  Dim Category As String
  Dim PromptCollection As AutoPromptCollection
  Dim PromptCollections As New List(Of AutoPromptCollection)

  ' Global Settings
  GetAutoPromptCollections_AddFromAIPrompts(PromptCollections, finBL.Settings.GetAIRecordInsightsPromptsForRecordType(mRecordType), "General")
  
  ' Roles
  Dim UserRolePksList As ISListReadOnly = finBL.CurrentUser.GetRolesPkList()
  For Each Role As ISRoleRO In finBL.Roles
    If UserRolePksList.Exists(CStr(Role.Pk)) Then
      GetAutoPromptCollections_AddFromAIPrompts(PromptCollections, Role.GetAIRecordInsightsPromptsForRecordType(mRecordType), Role.Description)
    End If
  Next
  
  ' Built-in
  If mIncludeBuiltInAutoPrompts Then
    If PromptCollections.Count &lt;&gt; 0 Then Category = "Insights"
    PromptCollection = New AutoPromptCollection(Category)
    
    Select Case UCase(mRecordType)
      Case "ACCOUNT"
        PromptCollection.Add("Summarise Logs", "Give a general summary of all logs. Keep it brief but highlight the main points and also highlight if a log has an action date but is not yet complete. include only information from the 'Logs' section. Use a bulletted list or table if there are multiple items.")
        PromptCollection.Add("Upcoming Payments", "List all unpaid or future payments due. do not combine values, list each and every item in a table and, if an item is in the past, highlight the fact it is overdue. don't include items that are considered already paid. Interest is not a payment due and please don't include zero value items.")
        PromptCollections.Add(PromptCollection)
        
      Case "CLIENT"
        PromptCollection.Add("Summarise Logs", "Give a general summary of all logs. Keep it brief but highlight the main points and also highlight if a log has an action date but is not yet complete. include only information from the 'Logs' section. Use a bulletted list of table if there are multiple items.")
        PromptCollection.Add("Summarise Accounts", "Give a general summary of all accounts. Highlight any accounts that are 'overdue' and deprioritise any that are closed or archived.")
        PromptCollection.Add("Upcoming Payments", "Show upcoming payments in chronological order, highlighting any that are 'overdue' and noting any that are in the past. make sure you include account, date, amount. show as a table. Make sure you format dates correctly.")
        PromptCollection.Add("Contacts", "List all current contact methods and addresses for this client")
        PromptCollection.Add("Lending Overview", "Give an overview of this client's loans indicating whether they have had any problems paying on time. include a very clear disclaimer at the top that this information is based only on what has been made available to ai (this can be viewed by clicking the 'source' button at the top of the page).")
        PromptCollections.Add(PromptCollection)
    End Select
  End If
  
  Return PromptCollections
  
End Function

Private Sub GetAutoPromptCollections_AddFromAIPrompts(promptCollections As List(Of AutoPromptCollection),
                                                      aiPrompts As ISAIPrompts,
                                                      category As String)
            
  Dim PromptCollection As AutoPromptCollection
  
  ' Anything to add?
  If aiPrompts.Count = 0 Then Return

  ' Add
  PromptCollection = New AutoPromptCollection(Category)
  For Each AIPrompt As ISAIPrompt In aiPrompts
    PromptCollection.Add(AIPrompt.Caption, AIPrompt.Prompt)
  Next
  promptCollections.Add(PromptCollection)

End Sub

''' &lt;summary&gt;
'''  Get Insight.
''' &lt;/summary&gt;
Private Async Function GetInsight() As System.Threading.Tasks.Task(Of String)

  Dim BranchId As String
  Dim Json As String
  Dim InsightsObject As I_finAIQuestionable
  Dim obj As Object
  Dim Options As finAI.PromptOptions = New finAI.PromptOptions()
  Dim PreviousResponsesJson As String
  Dim PreviousResponses As List(Of QuestionAnswer)
  Dim Prompt As String
  Dim Question As String
  Dim QuestionableText As String
  Dim Response As finAI.TextResponse
  Dim Success As Boolean

  ' Assume Success
  Success = True
  
  ' Get Parameters
  With mCombinedParameters
    BranchId = .GetString("BranchId")
    Question = .GetString("Question")
    QuestionableText = .GetString("QuestionableText")
    PreviousResponsesJson = .GetString("PreviousResponses")
  End With
  If Len(PreviousResponsesJson) &lt;&gt; 0 Then
    If finBL.Runtime.WebUtilities.DeserialiseJsonStringToObject(PreviousResponsesJson, GetType(List(Of QuestionAnswer)), obj) Then
      PreviousResponses = DirectCast(obj, List(Of QuestionAnswer))
    Else
      ' Ignore
    End If
  End If
  
  ' Get Questinonable Object
  ' NOTE: Required for tool calling
  If Success Then
    Success = GetObjectForInsights(InsightsObject, "", "", "")
  End If
  
  ' Create Prompt
  Prompt = QuestionableText
  
  ' Set Engineering Messages
  With Options
    ' System Messages
    .EngineeringMessages_AddSystemMessage("only use the supplied information")
    .EngineeringMessages_AddSystemMessage("keep answers as brief as possible. no fluff")
    .EngineeringMessages_AddSystemMessage("in the time zone this database is in (" &amp; finBL.TimeZoneFunctions.GetTimeZoneDescriptionFromTimeZoneId(finBL.TimeZoneId) &amp; "), the current date and time is " &amp; finBL.FormatDateTime(finBL.TimeZoneFunctions.GetCurrentDatabaseDateTime()))
    .EngineeringMessages_AddSystemMessage("the preferred date format for responses is " &amp; finBL.DateFormatLong &amp; ". ensure you do not mix day and month order. Remember, only the US puts month before day")
    .EngineeringMessages_AddSystemMessage("don't show uneccessary workings or additional information unless specifically requested")
    If Not mConversationMode Then
      .EngineeringMessages_AddSystemMessage("this is not a conversation so never ask follow-up questions")
    End If
    
    ' Previous Responses (for chat context)
    If PreviousResponses IsNot Nothing Then
      For Each qa As QuestionAnswer In PreviousResponses 
        .EngineeringMessages_AddUserMessage(qa.q)
        .EngineeringMessages_AddAssistantMessage(qa.a)
      Next
    End If
    
    ' The current question being asked
    .EngineeringMessages_AddUserMessage(Question)
    
    ' Enable tool calling (e.g., if the AI thinks it needs more information about Transactions than is suplied
    .ToolCallableDocument = InsightsObject.GetAIQuestionableTextToolCallableDocument() 
  End With
  
  ' AI (logged to Document Manager)
  Response = Await finBL.AI.ExecuteGetPromptAsync_LoggedToDocumentManager(Prompt, mRecordType, mRecordId, BranchId, isefinAIServiceType.Unspecified, Options)
  
  If Response.Failed Then
    Return "[ERROR]" &amp; Response.ErrorMessage
  Else
    obj = New With {
      .ResponseText = Response.ResponseText,
      .ToolCalls = If(mDebug, Response.ToolCalls, Nothing)
    }
    If Not finBL.Runtime.WebUtilities.SerialiseObjectToJsonString(obj, Json) Then
      ' Ignore
    End If
  End If
  
  Return Json

End Function

Private Function GetObjectForInsights(ByRef insightsObject As I_finAIQuestionable,
                                      ByRef recordDescription As String,
                                      ByRef recordTypeDescription As String,
                                      ByRef branchId As String) As Boolean
                          
  Dim Success As Boolean
  
  ' Assume Success
  Success = True
  
  ' Initialise ByRef Parameters
  insightsObject = Nothing
  recordDescription = ""
  recordTypeDescription = ""
  branchId = ""

  ' Get Object
  Select Case UCase(mRecordType)
    Case "ACCOUNT"
      ' Account
      Dim Account As finAccount = finBL.CreateAccount()

      mRecordType = "Account"
      recordTypeDescription = "Account"
      
      If Account.Load(mRecordId) Then
        InsightsObject = Account
        branchId = Account.BranchId             
        recordDescription = Account.Name 
      Else
        Success = False
      End If

    Case "ACCOUNTAPP"
      ' Account Application
      Dim AccountApp As finAccountApp = finBL.CreateAccountApp()

      mRecordType = "AccountApp"
      recordTypeDescription = "Account Application"
      
      If AccountApp.Load(mRecordId) Then
        InsightsObject = AccountApp
        branchId = AccountApp.BranchId             
        recordDescription = AccountApp.Name 
      Else
        Success = False
      End If
      
    Case "CLIENT"
      ' Client
      Dim Client As finClient = finBL.CreateClient()

      mRecordType = "Client"
      recordTypeDescription = "Client"
      
      If Client.Load(mRecordId) Then
        InsightsObject = Client
        branchId = Client.BranchId             
        recordDescription = Client.Name 
      Else
        Success = False
      End If
    
    Case Else
      Success = False
      finBL.Error.ErrorBeginFormat("Unhandled Record Type '{0}'.", mRecordType)
  End Select
  
  Return Success

End Function



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

  ' Record
  Public RecordType As String
  Public RecordTypeDescription As String
  Public RecordId As String
  Public RecordDescription As String
  
  ' Other
  Public BranchId As String
  Public QuestionableText As String
  Public ServiceDetails As String  
  
  ' Lists
  Public AutoPromptCollections As New List(Of AutoPromptCollection)

  ' Configuration
  Public ConversationMode As Boolean
  Public IsClientManagement As Boolean

  Public Sub New()
  End Sub

End Class



Public Class AutoPromptCollection
  
  Public Category As String
  Public Prompts As New List(Of AutoPrompt)
  
  Public Sub New(category As String)
    
    Me.Category = category
    
  End Sub
  
  Public Sub Add(label As String,
                 prompt As String)
                 
    Me.Prompts.Add(New AutoPrompt With {
      .Label = label,
      .Prompt = prompt
    })

  End Sub
  
End Class



Public Class AutoPrompt
  
  Public Label As String
  Public Prompt As String
  
End Class



Public Class QuestionAnswer
  
  Public q As String
  Public a As String
  
End Class</Code>
    <Language>VisualBasic</Language>
    <Notes>System defined HTML Widget.

Allows a User to enquire about a particular record, e.g., a Client, using AI.</Notes>
    <PermissionKeyExecute />
    <RunWithoutPrompts>false</RunWithoutPrompts>
    <TemplateText>&lt;!-- Markdown Library BEGIN --&gt;
&lt;script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"&gt;&lt;/script&gt;
&lt;!-- Markdown Library END --&gt;

&lt;!-- Custom Styles BEGIN --&gt;
&lt;style&gt;
body &gt; div {
  background-color: var(--background-editable);
  padding: 8px;
  border-left: none;
}

#frmMain {
  max-width: 1024px;
  margin: 8px !important;
}

.container {
  width: 100%;
  max-width: 1024px;
  background: var(--background-default);
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.disclaimer-bar {
  background-color: var(--ctrl-mandatory-background);
  border-bottom: 1px solid var(--border-default);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.disclaimer-bar svg {
  color: #d97706;
  flex-shrink: 0;
}

.disclaimer-content {
  font-size: 13px;
  color: ##92400e;
  line-height: 1.4;
}

.disclaimer-content strong {
  font-weight: 600;
}

.disclaimer-source {
  color: var(--tags-outline-text-icon-border-brand-primary);  
  cursor: pointer;
  font-size: 11px;
  position: absolute;
  right: 12px;
  top: 12px;
}

.app-header {
  padding: 8px 16px 0px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.model-info {
  font-size: 12px;
  color: ##6b7280;
  margin-bottom: 4px;
  margin-top: 4px;
}

.chat-details {
  font-size: 12px;
  margin-bottom: 4px;
  margin-top: 4px;
}

#divAutoPrompts {
  margin-top: 8px;
}

.conversation {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.conversation &gt; div#divResultsContainer {
  flex-grow: 1;
  flex-shrink: 1;
  padding: 4px 12px 12px 12px;
  position: relative;
  overflow: auto;
}

.conversation &gt; div#divQuestionContainer {
  flex-grow:0;
  flex-shrink:0;
  overflow: auto;
  min-height: 0;
  padding: 8px;
}

.conversation textarea {
  border-radius: 6px;
  padding: 8px;
}

#divQuestionContainer button {
  background: var(--ai-colour);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  position: absolute;
}

.conversation textarea {
  border-bottom: 44px solid transparent !important;
}

.conversation button#cmdSend {
  bottom: 16px;
  left: 16px;
}

.conversation button#cmdClear {
  bottom: 16px;
  right: 16px;
  background: var(--background-default);
  color: var(--ai-colour);
  border: 1px solid var(--border-default);
}

div#divResults {
  display: flex;
  flex-direction: column;
  width: 100%;
  font-weight: normal;
}

.question {
  border-radius: 8px 0 8px 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 4px 8px;
  max-width: 80%;
  overflow-y: auto;
  overflow-x: hidden;
  align-self: flex-end;
  margin: 8px 0 8px 0;
  cursor: pointer;
  position: relative;
  font-size: 13px;
  
  //background: linear-gradient(to bottom, var(--text-regular-default) 60%, transparent), var(--color-status-informative-50);
  //-webkit-background-clip: text, border-box;
  //-webkit-text-fill-color: transparent;
  
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;  
}

.answer {
}

.error {
  color: red;
  font-size: 0.9em;
  margin-bottom: 8px;  
  padding: 8px;
}

input#txtQuestion {
}

#divQuestionableText {
  padding: 8px;
}

#divServiceDetails {
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.6;
}

.groups {
  display: flex;
  column-gap: 16px;
  row-gap: 0;
  flex-wrap: wrap;
}

.group {
  display: flex;
  flex-direction: row;
  padding: 2px;
  border-radius: 100px;
  border: 1px solid var(--border-default);
  margin: 0 0 8px 0;  
  align-items: center;  
  background: var(--theme-secondary-50);
}

.group .group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
  padding: 0 6px;
  letter-spacing: 0.05em;
}

.ai-preset-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  
  li {
    background-color: var(--background-default);
    border: 1px solid var(--border-default);
    border-radius: 100px;
    padding: 4px 8px;
    font-size: var(--font-size-caption);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    margin: 0;
    
    &amp;:hover {
      background-color: var(--background-default);
      border-color: var(--theme-secondary-500);
      color: var(--theme-secondary-500);
      box-shadow: 0 2px 4px rgba(0,0,0,0.05);
      transform: translateY(-1px);
    }
    
    &amp;:active {
      transform: translateY(0);
      background-color: var(--theme-secondary-100);
    }    
  }
}

/* --- AI Answer: The Self-Contained Card --- */
.ai-card {
    align-self: flex-start;
    background: var(--background-default);
    width: 100%;
    border: 1px solid var(--border-default);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    overflow: hidden; /* Ensures the accent bar doesn't bleed out */
    display: flex;
}

.ai-card.latest {
  border-color: var(--ai-colour);
}

/* The Colored Left Accent Bar */
.ai-accent-bar {
  width: 6px;
  background-color: var(--ai-colour);
  flex-shrink: 0;
}

.ai-body {
  padding: 20px;
  flex-grow: 1;
  position: relative;  
}

.ai-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--ai-colour);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ai-header:before {
  content: "\f890";
  font-family: fa-solid;
}

.ai-content {
  font-size: 14px;
  line-height: 1.6;
}

/* Styling for Tables within the card */
.ai-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  border: 1px solid #f1f5f9;
}

.ai-content th {
  text-align: left;
  padding: 8px;
  font-size: 12px;
  border-bottom: 2px solid var(--border-default);
}

.ai-content td {
  padding: 8px;
  border-bottom: 1px solid var(--border-default);
}

.ai-content p:last-child { margin-bottom: 0; }

.copy-btn {
  background: none;
  border: 1px solid var(--border-default);
  color: var(--text-regular-secondary);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  position: absolute;
  right: 8px;
  top: 8px;
}

.copy-btn:hover {
  color: var(--text-regular-default);
  border-color: var(--text-regular-secondary);
}

.copy-btn:before {
 content: "\f0c5";
 font-family: fa-regular;
}

.copied-to-clipboard {
  background-color: black;
  color: white;
  border-radius: 6px;
  display: none;
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translate(-50%, 0);
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  z-index:999;
}

.copied-to-clipboard:before {
  content: "Copied to clipboard";
}

.conversation-ended {
  display: flex;
  flex-direction: row;
  align-items: center;
  text-align: center;
  font-size: 12px;
  text-align:center;
  margin: 16px 0 16px 0;
  
  &gt; div {
    background-color: var(--ai-colour);
    flex-grow: 1;
    flex-shrink: 0;
    height:1px;
  }
  
  &gt; span {
    color: var(--ai-colour);
    flex-grow: 0;
    margin: 0 8px 0 8px;
  }
}
&lt;/style&gt;

&lt;style type="text/less"&gt;
.markdown {
  h1,h2,h3,h4,h5 {
    color: var(--ai-colour);
  }

  a {
    color: var(--tags-outline-text-icon-border-brand-primary);
  }
}

.toc {
  border: 1px solid var(--tags-outline-text-icon-border-brand-primary);
  border-radius: 4px;
  margin: 8px;
  padding: 0;

  .toc-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    column-gap: 8px;
    padding: 8px;
    font-weight: 700;
    color: var(--ai-colour);
  }

  .toc-toggle {
    // Down-pointing chevron that rotates when collapsed
    border: solid var(--ai-colour);
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 3px;
    transform: rotate(45deg);
    transition: transform 0.15s ease;
  }

  .toc-list {
    list-style: none;
    margin: 0;
    padding: 0 8px 8px 8px;

    a {
      color: var(--tags-outline-text-icon-border-brand-primary);
      text-decoration: none;
    }

    .toc-h2 { padding-left: 12px; }
    .toc-h3 { padding-left: 24px; }
  }

  &amp;.collapsed {
    .toc-list { display: none; }
    .toc-toggle { transform: rotate(-45deg); }
  }
}
&lt;/style&gt;
&lt;!-- Custom Styles END --&gt;


&lt;div id="frmMain" class="is-widget-content container" style="visibility:hidden"&gt;

  &lt;!-- Form Header --&gt;
  &lt;div&gt;
    &lt;!--&lt;div class="header"&gt;&lt;/div&gt;--&gt;
    &lt;div class="disclaimer-bar"&gt;
      &lt;svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"&gt;&lt;circle cx="12" cy="12" r="10"&gt;&lt;/circle&gt;&lt;line x1="12" y1="8" x2="12" y2="12"&gt;&lt;/line&gt;&lt;line x1="12" y1="16" x2="12.01" y2="16"&gt;&lt;/line&gt;&lt;/svg&gt;
      &lt;div class="disclaimer-content"&gt;
         &lt;strong&gt;AI can make mistakes.&lt;/strong&gt; Please verify important financial or other information.
         &lt;div class="disclaimer-source" onclick="ToggleView()"&gt;source&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="app-header"&gt;
      &lt;div style="font-weight: 700; font-size: 18px;"&gt;Record Insights&lt;/div&gt;
      &lt;div id="divServiceDetails" class="model-info"&gt;&lt;/div&gt;
      &lt;div id="divChatDetails" class="chat-details"&gt;&lt;/div&gt;
    &lt;/div&gt;
    
    &lt;!-- Tabs --&gt;
    &lt;div id="tabDetails" class="is-tabs"&gt;
      &lt;ul&gt;
        &lt;li tabId="General" icon="AI"&gt;Insights&lt;/li&gt;
        &lt;li tabId="Text"&gt;Source&lt;/li&gt;
      &lt;ul&gt;
    &lt;/div&gt;
  &lt;/div&gt;


  &lt;!-- Pages --&gt;
  &lt;div class="is-widget-form-body"&gt;

    &lt;!-- General --&gt;
    &lt;div id="pageGeneral"&gt;
      &lt;div class="conversation is-dock-fill"&gt;
        &lt;div id="divResultsContainer" class="panel"&gt;
          &lt;div id="divResults"&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        
        &lt;div id="divQuestionContainer" class="panel"&gt;
          &lt;div id="divAutoPrompts"&gt;&lt;/div&gt;        
          &lt;form onsubmit="cmdSend_Click(); return false"&gt;
            &lt;input id="txtQuestion"/&gt;
            &lt;button id="cmdSend" type="submit"&gt;Ask Question&lt;/button&gt;
            &lt;button id="cmdClear"&gt;Clear&lt;/button&gt;
          &lt;/form&gt;
          &lt;div id="divCopiedtoClipboard" class="copied-to-clipboard"&gt;&lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;



    &lt;!-- Text --&gt;
    &lt;div id="pageText"&gt;
      &lt;div class="is-dock-fill"&gt;
          &lt;div id="divToc" class="toc"&gt;&lt;/div&gt;
          &lt;div id="divQuestionableText" class="panel markdown"&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    
  &lt;/div&gt;

&lt;/div&gt;

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

// Controls
var C = {
  // General
  divResultsContainer: null,
  divResults: null,
  divAutoPrompts: null,
  txtQuestion: null,
  cmdSend: null,
  cmdClear: null,

  // Text
  divQuestionableText: null,
  divToc: null,
}

// Form
var frmMain;
var tabDetails;

// Other
var mDivThinking;
var mFetching = false;
var mAnswerCounter = 0;
var mPreviousResponses = [];

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

  // Controls
  //   General
  C.divResultsContainer = $("#divResultsContainer");
  C.divResults = $("#divResults");
  C.divAutoPrompts = $("#divAutoPrompts");
  C.txtQuestion = widget.UI.TextBox("txtQuestion", {
    blankTip: "Ask a question about this record...",
    multiLine: true,
    rows: 5,
  });
  C.cmdSend = $("#cmdSend");
  C.cmdClear = $("#cmdClear");
  C.cmdClear.on("click", cmdClear_Click);
  
  
  //   Text
  C.divQuestionableText = $("#divQuestionableText");
  C.divToc = $("#divToc");

  // 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: "wizard",
    onSelectedTabChanged: tabDetails_Refresh,
    
  });

  // Handle Notifications
  widget.ActionNotificationHandle(Widget_NotificationHandler);
  
  // Allow Enter to be used to submit question
  var textarea = C.txtQuestion.Element()[0];
  textarea.addEventListener("keydown", (e) =&gt; {
      if (e.key === "Enter" &amp;&amp; !e.shiftKey) {
          e.preventDefault();
          textarea.form.requestSubmit();
      }
  });  

  // Reset
  Form_Reset();
});

// ==========
// Form Reset
// ==========
function Form_Reset() {
  // Set Tab
  tabDetails.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) {
  }

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

  // Update Controls
  
  /// Auto-Prompts
  C.divAutoPrompts.children().remove();
  var groups = $("&lt;div class='groups'&gt;&lt;/div&gt;");
  C.divAutoPrompts.append(groups);
  for (var i = 0; i &lt; mRecord.AutoPromptCollections.length; i++) {
    var collection = mRecord.AutoPromptCollections[i];
    var el = $("&lt;div class='group'&gt;&lt;/div&gt;");
    if (collection.Category) {
      el.append("&lt;span class='group-label'&gt;" + widget.UI.HtmlEncode(collection.Category) + "&lt;/span&gt;");
    }    
    var ul = $("&lt;ul class='ai-preset-list'&gt;&lt;/ul&gt;");
    el.append(ul);
    groups.append(el);
    
    for (var j = 0; j &lt; collection.Prompts.length; j++) {
      var prompt = collection.Prompts[j];
      var li = $("&lt;li&gt;&lt;/li&gt;");
      li.text(prompt.Label);
      li.attr("prompt", prompt.Prompt);
      ul.append(li);
    }
  }
  $("li", C.divAutoPrompts).click(function () {
    if (!mFetching) {
      ClearConversation(false);
      C.txtQuestion.Text($(this).attr("prompt"));
      C.cmdSend.click();
    }
  });
  
  // Questionable Text is in Markdown and use "marked" to render it
  // NOTE: Not sanitised since this is not user generated markdown
  var html = marked.parse(mRecord.QuestionableText);
  C.divQuestionableText.html(html);

  // Build the Table of Contents from the rendered headings
  Toc_Build();

  // Update fields
  Fields_Update();

  // Refresh Tab
  tabDetails_Refresh();
}

// =========
// TOC Build
// =========
function Toc_Build() {
  // Reset
  C.divToc.children().remove();

  // Find headings in the rendered source (only the structural levels)
  var headings = $("h1, h2, h3", C.divQuestionableText);

  // Nothing to index? Hide the TOC entirely
  if (headings.length === 0) {
    C.divToc.hide();
    return;
  }
  C.divToc.show();

  // Header (click to collapse/expand)
  var header = $("&lt;div class='toc-header'&gt;&lt;/div&gt;");
  header.append("&lt;span class='toc-toggle'&gt;&lt;/span&gt;");
  header.append("&lt;span class='toc-title'&gt;Contents&lt;/span&gt;");
  header.on("click", Toc_Toggle);
  C.divToc.append(header);

  // List
  var list = $("&lt;ul class='toc-list'&gt;&lt;/ul&gt;");
  headings.each(function (i) {
    var heading = $(this);

    // Assign an id to the rendered heading so we can scroll to it
    // NOTE: We add the id to the rendered DOM, never to the source text
    var id = "toc-heading-" + i;
    heading.attr("id", id);

    var li = $("&lt;li class='toc-" + this.tagName.toLowerCase() + "'&gt;&lt;/li&gt;");
    var a = $("&lt;a&gt;&lt;/a&gt;");
    a.text(heading.text());
    a.attr("href", "#" + id);
    a.on("click", Toc_Item_Click);
    li.append(a);
    list.append(li);
  });
  C.divToc.append(list);

  // Default to expanded
  C.divToc.removeClass("collapsed");
}

// ==========
// TOC Toggle
// ==========
function Toc_Toggle() {
  C.divToc.toggleClass("collapsed");
}

// ==============
// TOC Item Click
// ==============
function Toc_Item_Click(e) {
  e.preventDefault();

  // Scroll the targeted heading into view
  var id = $(this).attr("href").substring(1);
  var target = document.getElementById(id);
  if (target) {
    target.scrollIntoView({ behavior: "smooth", block: "start" });
  }
}

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

  // Lists

  // Controls
  if(mRecord) {
    if (tabDetails.TabCountVisible() &lt; 2) tabDetails.Style("wizard");
    
    
    // Update heading
    widget.SetHeading(mRecord.RecordTypeDescription + " (" + mRecord.RecordId + ")");
    $("#divServiceDetails").text("Using " + mRecord.ServiceDetails);
    if (mRecord.ConversationMode) {
      //msg += "&lt;b&gt;Conversation mode&lt;/b&gt;. You can ask a question and then ask follow-up questions.";
      $("#divChatDetails").hide();
    }
    else {
      $("#divChatDetails").html("&lt;b&gt;Single Question mode&lt;/b&gt;. You cannot ask follow-up questions.");
    }
    
  }

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

  // Resize
  tabDetails_Resize();
}

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

    default:
      break;
  }

  // Update Heading
  switch (tabDetails.SelectedTabId()) {
    default:
      frmMain.RefreshHeading(tabDetails.TabCaption(tabDetails.SelectedTabId()), tabDetails.TabTooltipText(tabDetails.SelectedTabId()));
      break;
  }

  // Resize
  tabDetails_Resize();

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

function tabDetails_Resize() {
  switch (tabDetails.SelectedTabId()) {
    case "General":
      C.txtQuestion.WidthResizeFromParent();
      break;

    default:
      break;
  }
}

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

function Form_Resize() {
  // General

  // Tab
  tabDetails_Resize();
}

// ====================
// Notification Handler
// ====================
function Widget_NotificationHandler(actionId, data) {
  switch(actionId) {
  }
}

// ===========
// Get Insight
// ===========
function GetInsight(question) {
  // Already fetching?
  if (mFetching) return;
  mFetching = true;
  
  // Just in case we're viewing source
  tabDetails.SelectedTabIndex(0);  
  
  // Latest is highlighted
  $("div.latest").removeClass("latest");  
  
  // Parameters
  var params = {
    branchId: mRecord.BranchId,
    question: question,
    questionableText: mRecord.QuestionableText,
    previousResponses: mPreviousResponses,
  }
  
  // Append question
  Results_Append(C.txtQuestion.Text());
  
  // Append "thinking" animation
  if (mDivThinking) {
    mDivThinking.remove();
    mDivThinking = null;
  }
  mDivThinking = $("&lt;div class='ai-thinking-pulse'&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;");
  C.divResults.append(mDivThinking);
  
  // Lock
  C.txtQuestion.ReadOnly(true);
  C.txtQuestion.Focus();
  C.cmdSend.hide();
  C.cmdClear.hide();

  // Get Insight
  widget.GetString("GetInsight", params,
    function (data) {
      // Parse
      var responseText;      
      try {
        data = JSON.parse(data);
        responseText = data.ResponseText;
      }
      catch(ex) {
        // Ignore, data will still be in string format, e.g., an error
        responseText = data;
      }
      
      // Show Answer
      Results_Append(params.question, responseText, null);
      
      // Debug
      if (data.ToolCalls &amp;&amp; data.ToolCalls.length != 0) {
        console.log("The following Tool Calls were made:")
        for (var i = 0; i &lt; data.ToolCalls.length; i++) {
          var item = data.ToolCalls[i];
          console.log("function: " + item.ToolName);
          console.log("parameters: " + item.Parameters);
          console.log("result: " + item.Result);
        }
      }
      
      // Unlock
      GetInsight_Unlock();
    },

    function (data) {
      // Show Error
      Results_Append(null, null, data);
      
      // Unlock
      GetInsight_Unlock();
    }
  );
}

function GetInsight_Unlock() {
  C.txtQuestion.ReadOnly(false);
  C.cmdSend.show();
  C.cmdClear.show();
  mFetching = false;

  // Remove "thinking" animation
  if (mDivThinking) {
    mDivThinking.remove();
    mDivThinking = null;
  }
}


// =================
// Append to Results
// =================
function Results_Append(question, answer, error) {
  // Just in case answer is an error
  if (answer &amp;&amp; answer.startsWith("[ERROR]")) {
    error = answer.substr(7);
    answer = "";
  }

  if (question &amp;&amp; !answer &amp;&amp; !error) {
    var el = $("&lt;div class='question'&gt;" + widget.UI.HtmlEncode(question)  + "&lt;/div&gt;");
    el.on("click", function () {
      C.txtQuestion.Text(question);
      C.txtQuestion.Focus();
    });
    C.divResults.append(el);
  }
  
  if (answer) {
    // Assume answer is in Markdown and use "marked" to render it
    // NOTE: Not sanitised since this is not user generated markdown
    mAnswerCounter += 1;
    var id = "isa" + mAnswerCounter;
    var html = marked.parse(answer);
    C.divResults.append("&lt;div class='ai-card markdown latest'&gt;&lt;div class='ai-accent-bar'&gt;&lt;/div&gt;&lt;div class='ai-body'&gt;&lt;div class='ai-header'&gt;AI Response&lt;/div&gt;&lt;button class='copy-btn' title='Copy to clipboard' onclick='CopyToClipboard(\"" + id + "\");'&gt;Copy&lt;/button&gt;&lt;div class='ai-content' id='" + id + "'&gt;" + html + "&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;");
    
    // Record for chat context
    if (mRecord.ConversationMode) {
      mPreviousResponses.push({q:question, a:answer});
    }
    
    // End conversation?
    if (!mRecord.ConversationMode) {
      C.divResults.append("&lt;div class='conversation-ended'&gt;&lt;div&gt;&lt;/div&gt;&lt;span&gt;conversation ended&lt;/span&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;");    
    }
  }
  
  if (error) C.divResults.append("&lt;div class='error'&gt;" + widget.UI.HtmlEncode(error)  + "&lt;/div&gt;");
  
  // Scroll to the bottom
  C.divResultsContainer.animate({ scrollTop: C.divResultsContainer[0].scrollHeight }, 500);
}

// =======
// cmdSend
// =======
function cmdSend_Click() {
  // Already fetching?
  if (mFetching) return;

  if (C.txtQuestion.Text()) {
    GetInsight(C.txtQuestion.Text());
    C.txtQuestion.Text("");
  }
  else {
    C.txtQuestion.Focus();
  }
}

// ========
// cmdClear
// ========
function cmdClear_Click() {
  ClearConversation(true);
  C.txtQuestion.Text("");
  C.txtQuestion.Focus();
  
  // Prevent form submission
  return false;
}

// =======================
// Toggle Source/ Insights
// =======================
function ToggleView() {
  if (tabDetails.SelectedTabIndex() == 0) {
    tabDetails.SelectedTabIndex(1);
  }
  else {
    tabDetails.SelectedTabIndex(0);
  }
}

// =================
// Copy to Clipboard
// =================
async function CopyToClipboard(id) {
  var html = $("#" + id).html();
  var text = $("#" + id).text();
  
  const blobHtml = new Blob([html], { type: "text/html" });
  const blobText = new Blob([text], { type: "text/plain" });

  const data = [new ClipboardItem({
          ["text/html"]: html,
          ["text/plain"]: text
      })];
      
  try {
        await navigator.clipboard.write(data);
        $("#divCopiedtoClipboard").show();
        
        setTimeout(() =&gt; {
            $("#divCopiedtoClipboard").fadeOut();
        }, 1000);
        
    } catch (err) {
      console.error("Copy failed", err);
      alert("Unable to copy to clipboard.");
    }
}

function ClearConversation(clearResults) {
  // Already fetching?
  if (mFetching) return;

  if (clearResults) {
    C.divResults.children().remove();
  }
  else if (mPreviousResponses.length != 0) {
   C.divResults.append("&lt;div class='conversation-ended'&gt;&lt;div&gt;&lt;/div&gt;&lt;span&gt;conversation ended&lt;/span&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;");
  }
  mPreviousResponses = [];
}
&lt;/script&gt;</TemplateText>
    <TemplateTextBookmarks />
    <UniqueId>S8+Q4OCFEkW9n1W77Csbrw</UniqueId>
    <AllowRefresh>true</AllowRefresh>
    <Caption>Insights</Caption>
    <HtmlWidgetAllowInitialEventCaching>true</HtmlWidgetAllowInitialEventCaching>
    <HtmlWidgetMaxHeight>0</HtmlWidgetMaxHeight>
    <HtmlWidgetMaxWidth>1200</HtmlWidgetMaxWidth>
    <HtmlWidgetDarkModeNotSupported>false</HtmlWidgetDarkModeNotSupported>
    <HtmlWidgetNeverApplyStyling>false</HtmlWidgetNeverApplyStyling>
    <HtmlWidgetResourceChartsApex>true</HtmlWidgetResourceChartsApex>
    <HtmlWidgetResourceCssSummaryPage2>false</HtmlWidgetResourceCssSummaryPage2>
    <HtmlWidgetResourceCssWidget>true</HtmlWidgetResourceCssWidget>
    <HtmlWidgetResourceJQuery>true</HtmlWidgetResourceJQuery>
    <HtmlWidgetResourceJQueryVersion />
    <HtmlWidgetShowParameterEntry>false</HtmlWidgetShowParameterEntry>
    <HtmlWidgetSpecialEventGetFolderCount>false</HtmlWidgetSpecialEventGetFolderCount>
    <HtmlWidgetSpecialEventShowAsSummaryPage>false</HtmlWidgetSpecialEventShowAsSummaryPage>
    <HtmlWidgetSummaryPageObjectType>None</HtmlWidgetSummaryPageObjectType>
    <Icon>AI</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>Options.</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="IncludeBuiltInAutoPrompts" type="Boolean">
            <BlankTip />
            <Caption>Show built-in "Auto Prompts"?</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="ConversationMode" type="Boolean">
            <BlankTip />
            <Caption>Enable conversation mode (uses far more AI tokens)?</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>
          <Parameter name="Debug" 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>
          <Parameter name="" type="SectionStart">
            <BlankTip />
            <Caption>TESTING</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText>These are the Parameters required by this HTML Widget to function correctly.
They are listed here for testing purposes only.</TooltipText>
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="RecordType" 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>Account,AccountApp,Client</List>
            <LimitToList>false</LimitToList>
            <MaxLength>0</MaxLength>
            <Rows>1</Rows>
          </Parameter>
          <Parameter name="RecordId" type="Text">
            <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>
            <MaxLength>30</MaxLength>
            <Rows>1</Rows>
          </Parameter>
        </Parameters>
      </ISParameterDefs>
    </Parameters>
  </finScript>