<?xml version="1.0" encoding="utf-8"?>
  <finDocument version="1.00" exportedUtcDate="2022-04-12T20:42:40.0000000">
    <CreatedUserId>Admin</CreatedUserId>
    <CreatedUtcDate>2022-04-12T20:41:53.2530000</CreatedUtcDate>
    <UpdatedUserId>Admin</UpdatedUserId>
    <UpdatedUtcDate>2022-04-12T20:41:53.2530000</UpdatedUtcDate>
    <Active>true</Active>
    <AllowLog>true</AllowLog>
    <AllowStandalone>true</AllowStandalone>
    <AutoSaveDocument>true</AutoSaveDocument>
    <AutoPublishPriority>5</AutoPublishPriority>
    <Category />
    <CreateLog>true</CreateLog>
    <ChargeFee>false</ChargeFee>
    <CloudConnectAvailable>true</CloudConnectAvailable>
    <CloudConnectAllowPublish>true</CloudConnectAllowPublish>
    <DefaultPublishStatus>ToSend</DefaultPublishStatus>
    <Description>Account Application Letter</Description>
    <DocumentEmailCopyOfPrimary>false</DocumentEmailCopyOfPrimary>
    <DocumentEmailDoNotCombineForJoints>false</DocumentEmailDoNotCombineForJoints>
    <DocumentId>AAL</DocumentId>
    <DocumentLogSubject>Account Application Letter</DocumentLogSubject>
    <DocumentType>AccountApp</DocumentType>
    <EmailHTML>false</EmailHTML>
    <Fee>0</Fee>
    <FeeNotes />
    <FeeReference />
    <FeeElementId />
    <FileName>AccountApp_Letter.docx</FileName>
    <FileType>WordDocument</FileType>
    <LogConfirmPrinted>false</LogConfirmPrinted>
    <Notes>This is an example Account Application Letter than can be published either via an Account Application Log or Standalone (e.g., via the Report Explorer).

When publishing Standalone, it uses the standard Account Application parameters to produce a filtered list of Account Applications.

It also has a "LetterContent" parameter into which basic letter content can be entered.


RUNNING THIS DOCUMENT STANDALONE (AD-HOC)
====================================
1. On the "Options" page:
  a) Ensure "Allow Standalone running of this Document" is checked

2. Use the Script Constants to control whether a Bulk document and/ or individual Account Application documents are saved to the Document Manager.


EMAILING THE DOCUMENT
===================
If you wish to Email this Document:

1. On the "Options" page:
  a) Set "Email" to either "Yes" or "Prompt"
  b) If the Email will contain personalised, Applicant information such as Applicant Name, ensure the "Emails contain personalised details so do not combine for 'Joint' Applicants?" option is checked.
  c) Ensure "Create Log" is checked if running Standalone to ensure a Log is created to record the Emails

2. On the "Document" page:
  a) Specify a template Email Subject and Message
  b) If these are blank then the Script will need to be updated to manually generate the Subject and Message at the end of the CreateDocument function.

3. It is generally best to ensure that a hard-copy of the Document is also saved so ensure that "Save Document Automatically" is checked on the "Options" page.

NOTE: If not Emailing or if an Email could not be sent (for technical reasons or because a Applicant does not have a current Email Address) then the Script will set the Account Application Log to "Print Pending" which means the Document will be included in the Print Documents wizard.</Notes>
    <ParameterSetId />
    <ParametersType>Custom</ParametersType>
    <PermissionKeyExecute />
    <ShowInReportExplorer>true</ShowInReportExplorer>
    <SplitDocumentByPostalZone>false</SplitDocumentByPostalZone>
    <UserFlagA>false</UserFlagA>
    <UserFlagB>false</UserFlagB>
    <SendToAccountOwners>All</SendToAccountOwners>
    <SendToAccountGuarantors>true</SendToAccountGuarantors>
    <SendToAccountOther>false</SendToAccountOther>
    <SendToAccountJoints>false</SendToAccountJoints>
    <EmbedDocumentInLog>false</EmbedDocumentInLog>
    <EmailDocument>Prompt</EmailDocument>
    <DoNotEmailDocumentForStandalone>false</DoNotEmailDocumentForStandalone>
    <EmailClientCommunicationType>NotApplicable</EmailClientCommunicationType>
    <PrintDocumentEvenIfEmailed>false</PrintDocumentEvenIfEmailed>
    <PrintOnPublish>true</PrintOnPublish>
    <TemplateMessage>Please review the attached letter.</TemplateMessage>
    <TemplateSubject>Letter from [Branch.Name] re: Application [AccountApp.AccountAppId]</TemplateSubject>
    <TemplateDocumentBinaryData>H4sIAAAAAAAEAO17VVRc29Ju4+4Owd3dgjuNu7sFdydAAoHg7i7BLbi7S+MS3IIEDe5w2eecffc++XMe7tP/cM/XY63uNWt9NdZYXTVrzpo1lWQhIDEB0ABYAABACpBpA3eyAwMAaKABAAwALLiumIO9q7m9q6Gal6O5iz6Tp50tSR4kOE0OABzwX/x/jbqEUeteFlSJm6D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/Low/Bd+4v5mmfhX+q+5/L/wnvj3mf1fNfx75vrvmCQBAP5HHvtX+q/ZxL/gQ/4/cou/kn8dQfyFPubfjSd+5f97vPg7sNn+9uz/ih5KslDQf8iQXj/CrwYuyvnH1f8B9QGbHZg4AAA=</TemplateDocumentBinaryData>
    <Code>Option Explicit On
Option Strict On

' #################################################################
' Account Application Letter
'
' Version: 1.02 (13/04/2022)
'
' Usage:
'  Sample
' #################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    1.01  15/09/2017  ISS
'    1.02  13/04/2022  ISS      J028597   Updated to use ExecuteDisconnectedDataReader
' #################################################################

'#const "CreateBulkDocument",Boolean,False,"Indicates whether, when running Ad-Hoc, to create a Bulk Document containing all of the Account Documents combined."
'#const "CreateIndividualDocuments",Boolean,True,"Indicates whether, when running Ad-Hoc, to create a Document for each Account."

' Constants
Private CreateBulkDocument As Boolean = True
Private CreateIndividualDocuments As Boolean = True

' Objects
Private mDocument As finDocumentRO
Private mWordDocuments As List(Of ISWordDocument)
Private mWordDocumentsAccountApp As List(Of ISWordDocument)

' Other
Private mBulkDocumentFileName As String

Public Function Main(source As Object, eventId As String, eventArgs As ISKeyValueList, ByRef handled As Boolean, parameters As Object, ByRef returnValues As ISKeyValueList, ByRef text As String) As Boolean

  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise
  mDocument = finBL.Documents(Mid(ScriptInfo.ScriptId, 10))
  mWordDocuments = New List(Of ISWordDocument)
  mWordDocumentsAccountApp = New List(Of ISWordDocument)

  ' Get Constants
  With ScriptInfo.Constants
    CreateBulkDocument = .GetBoolean("CreateBulkDocument", CreateBulkDocument)
    CreateIndividualDocuments = .GetBoolean("CreateIndividualDocuments", CreateIndividualDocuments)
  End With

  ' Handle Events
  Select Case eventId
    Case "Publish"
      ' Publish
      If TypeOf source Is finLogPublishBatch Then
        ' Log Publish
        Success = Publish_Log(DirectCast(source, finLogPublishBatch)(0))
      Else
        ' Standalone (Ad-Hoc)
        Success = Publish_Standalone(DirectCast(parameters, ISKeyValueList))

        ' Return Bulk Document File Name
        If Success AndAlso CreateBulkDocument Then
          returnValues.SetString("BulkDocumentFileName", mBulkDocumentFileName)
        End If
      End If
  End Select

  Return Success

End Function

'#################################################################
' Publish via Log
'#################################################################
Private Function Publish_Log(logPublishBatchItem As finLogPublishBatchItem) As Boolean

  Dim dis As finDocumentRecipientDetailsItems
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate

  ' Get Document Recipient Details for relevant Applicants
  If Success Then
    Success = mDocument.GetAccountAppDocumentRecipientDetailsItemsFromLogPublishBatchItem(logPublishBatchItem, dis)
  End If

  ' Validate (Account Applications may have no Applicants)
  If Success AndAlso dis.Count = 0 Then
    Success = False
    logPublishBatchItem.PublishSuccess = False
    logPublishBatchItem.PublishError = "No Applicants were included for this Document."
  End If

  ' Create Document
  If Success Then
    If Not CreateAccountAppDocument(dis, logPublishBatchItem, logPublishBatchItem.LogPk, Nothing) Then
      ' Ignore errors since the status of logPublishBatchitem will be updated to record this
    End If
  End If

  Return Success

End Function

'#################################################################
' Publish Standalone (Ad-Hoc)
'#################################################################
Private Function Publish_Standalone(parameters As ISKeyValueList) As Boolean

  Dim AccountApp As finAccountApp
  Dim AccountAppLog As finAccountAppLog
  Dim AccountAppLogPk As Integer
  Dim AccountAppLogPks As List(Of Integer)
  Dim di As finDocumentRecipientDetailsItem
  Dim dis As finDocumentRecipientDetailsItems
  Dim DocumentManagerFileName As String
  Dim DocumentManagerFileNameRelative As String
  Dim dr As IDataReader
  Dim sqb As ISSelectQueryBuilder
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Validate

  If Success Then
    ' Create Objects
    AccountAppLogPks = New List(Of Integer)

    ' Create Query (can use DocumentFunctions since we are using Standard Parameters)
    sqb = finBL.DocumentFunctions.GetAccountAppSqlSelectQueryBuilder(parameters)

    ' Execute Query
    If sqb.ExecuteDisconnectedDataReader(dr) Then
      Do While dr.Read()
        ' Load Account Application
        AccountApp = finBL.CreateAccountApp()
        If Not AccountApp.LoadPk(finBL.Database.GetFieldInteger(dr!Pk)) Then
          Success = False
          Exit Do
        End If

        ' Get Document Recipient Details for relevant Applicants
        If Not mDocument.GetAccountAppDocumentRecipientDetailsItems(AccountApp, dis, Nothing, parameters) Then
          Success = False
          Exit Do
        End If

        ' Create Document
        ' NOTE: Will also create and return an Account Application Log if neccessary
        If CreateAccountAppDocument(dis, Nothing, 0, AccountAppLog) Then
          ' Record Account Application Log so it can be updated with the Bulk Document File Name later
          If AccountAppLog IsNot Nothing Then
            AccountAppLogPks.Add(AccountAppLog.Pk)
          End If

          ' Remove entries for Emailed Documents so they are not included in the Bulk Document since this would typically be used to Print Document that were not Emailed
          If CreateBulkDocument Then
            For Each di In dis
              If di.EmailDetails.EmailSent Then
                ' Remove Word Document so it is not included in the Bulk Document
                mWordDocuments.Remove(di.WordDocument)

                ' Remove Log so it is not updated to refer to the Bulk Document
                If AccountAppLog IsNot Nothing Then
                  AccountAppLogPks.Remove(AccountAppLog.Pk)
                End If
              End If
            Next
          End If
        Else
          Success = False
          Exit Do
        End If
      Loop
      finBL.Database.DataReaderClose(dr)
    Else
      Success = False
    End If

    ' Save Bulk Document
    If Success AndAlso CreateBulkDocument AndAlso mWordDocuments.Count &lt;&gt; 0 Then
      ' Save Document
      If mWordDocuments.Count = 0 Then
        ' No Documents created, e.g., no Used Applicants
      Else
        If finBL.DocumentManagerFunctions.SaveWordDocumentsToDocumentManagerPdfAccountApp("", mWordDocuments, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative) Then
          mBulkDocumentFileName = DocumentManagerFileName
        Else
          Success = False
        End If
      End If

      ' Update Account Application Logs to refer to Bulk Document (if not creating individual Documents)
      If Success AndAlso Not CreateIndividualDocuments Then
        For Each AccountAppLogPk In AccountAppLogPks
          With AccountAppLog
            If .Load(AccountAppLogPk) Then
              .DocumentFileName = DocumentManagerFileNameRelative

              If Not .Save() Then
                ' Ignore Errors
              End If
            Else
              ' Ignore Errors
            End If
          End With
        Next
      End If
    End If
  End If

  Return Success

End Function

'#################################################################
' Create Document for relevant Account Application Applicants
'#################################################################
Private Function CreateAccountAppDocument(dis As finDocumentRecipientDetailsItems,
                                          logPublishBatchItem As finLogPublishBatchItem,
                                          parentLogPk As Integer,
                                          ByRef accountAppLog As finAccountAppLog) As Boolean

  Dim di As finDocumentRecipientDetailsItem
  Dim DocumentManagerFileName As String
  Dim DocumentManagerFileNameRelative As String
  Dim DocumentBinaryData As Byte()
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise
  mWordDocumentsAccountApp.Clear()

  If dis.Count = 0 Then
    ' No Included Applicants
    ' NOTE: This is perfectly legitimate for Account Applications
  Else
    ' Create Document for all relevant Applicants
    For Each di In dis
      ' Create Document
      If Not CreateDocument(di) Then
        Success = False
        Exit For
      End If
    Next

    ' Standalone Publish functionality
    If Success Then
      If logPublishBatchItem Is Nothing Then
        ' Embed in Log?
        If mDocument.EmbedDocumentInLog Then
          Success = finBL.PdfUtilities.CombineWordDocumentsToPdfByteArray(mWordDocumentsAccountApp, DocumentBinaryData)
        End If

        ' Save Individual Document for this Account Application?
        If Success AndAlso CreateIndividualDocuments Then
          Success =  finBL.DocumentManagerFunctions.SaveWordDocumentsToDocumentManagerPdfAccountApp(dis(0).AccountAppId, mWordDocumentsAccountApp, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative)
        End If

        ' Create Log
        If Success AndAlso mDocument.CreateLog Then
          If finBL.AccountAppFunctions.LogAddDocument(dis(0).AccountApp.Pk, dis(0).AccountAppApplicant.Pk, mDocument.DocumentId, accountAppLog, mDocument.DocumentLogSubjectResolved, "", DocumentManagerFileNameRelative, "", isefinLogEmbeddedFileType.Pdf, DocumentBinaryData) Then
            ' Ensure any Email Logs are linked to this new Log
            parentLogPk = accountAppLog.Pk
          Else
            Success = False
          End If
        End If
      End If
    End If

    ' Save Combined Document to Document Manager?
    ' NOTE: This is for ALL Account Application Applicants, regardless of whether individual documents will be saved for each Applicant
    If Success AndAlso mDocument.AutoSaveDocument Then
      If logPublishBatchItem IsNot Nothing OrElse mWordDocumentsAccountApp.Count &gt; 1 Then
        Success = finBL.DocumentManagerFunctions.SaveWordDocumentsToDocumentManagerPdfAccountApp(di.AccountAppId, mWordDocumentsAccountApp, mDocument.FileName, DocumentManagerFileName, DocumentManagerFileNameRelative)
      End If
    End If

    ' Embed Combined Document in Log?
    ' NOTE: This is for ALL Account Application Applicants, regardless of whether individual documents will be saved for each Applicant
    If Success AndAlso mDocument.EmbedDocumentInLog Then
      Success = finBL.PdfUtilities.CombineWordDocumentsToPdfByteArray(mWordDocumentsAccountApp, DocumentBinaryData)
    End If

    ' Email Applicants?
    ' NOTE: This will create additional Account Application Logs (for each Applicant) where neccessary
    If Success AndAlso dis(0).EmailDetails.PublishEmail Then
      Success = dis.SendAccountAppEmailsPdf(parentLogPk)
    End If
  End If

  ' Update Log Publish details
  If logPublishBatchItem IsNot Nothing Then
    With logPublishBatchItem
      If Success Then
        ' Success
        .PublishSuccess = True
        .PublishDocumentFileName = DocumentManagerFileNameRelative
        .PublishDocumentBinaryDataFileType = isefinLogEmbeddedFileType.Pdf
        .PublishDocumentBinaryData = DocumentBinaryData
        If dis.Count &lt;&gt; 0 Then .PrintStatus = dis(0).PrintStatus
      Else
        ' Failure
        .PublishSuccess = False
        .PublishError = finBL.Error.Message(True, True)
      End If
    End With
  End If

  Return Success

End Function

'#################################################################
' Create Document
'#################################################################
Private Function CreateDocument(di As finDocumentRecipientDetailsItem) As Boolean

  Dim Success As Boolean
  Dim WordDocumentBookmarks As ISWordDocumentBookmarks

  ' Assume Success
  Success = True

  ' Get Bookmarks
  WordDocumentBookmarks = di.WordDocument.GetBookmarks()

  ' Replace Standard Bookmarks
  Success = di.UpdateStandardBookmarks(WordDocumentBookmarks)

  ' Replace Custom Bookmarks
  If Success Then
    ReplaceBookmarks(di, WordDocumentBookmarks)
  End If

  ' Update Bookmarks
  If Success Then
    Success = di.WordDocument.UpdateBookmarks(WordDocumentBookmarks)
  End If

  ' Record Word Document
  If Success Then
    mWordDocuments.Add(di.WordDocument)
    mWordDocumentsAccountApp.Add(di.WordDocument)
  End If

  ' Update di Email details if required
  ' NOTE: By default, these are set to the Email template details defined on this Document

  Return Success

End Function

'#################################################################
' CUSTOM BOOKMARKS
'#################################################################
Private Function ReplaceBookmarks(di As finDocumentRecipientDetailsItem,
                                  wordDocumentBookmarks As ISWordDocumentBookmarks) As Boolean

  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Parameters
  If Success Then
    With wordDocumentBookmarks
      .SetContentString("LetterContent", di.Parameters.GetString("LetterContent"))
    End With
  End If

  Return Success

End Function</Code>
    <Language>VisualBasic</Language>
    <TimeoutSeconds>0</TimeoutSeconds>
    <ScriptReferenceReports>false</ScriptReferenceReports>
    <Parameters>
      <ISParameterDefs version="1.00">
        <Parameters>
          <Parameter name="" type="PageStart">
            <BlankTip />
            <Caption>Letter Content</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
          </Parameter>
          <Parameter name="" type="SectionStart">
            <BlankTip />
            <Caption>Specify Letter Content.</Caption>
            <StandaloneOnly>false</StandaloneOnly>
            <TooltipText />
            <SectionColumns>1</SectionColumns>
            <Visible>true</Visible>
          </Parameter>
          <Parameter name="LetterContent" 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>Replace with the body of letter.</Value>
            <Visible>true</Visible>
            <MaxLength>0</MaxLength>
            <Rows>8</Rows>
          </Parameter>
          <Parameter name="" type="IncludeStandardParameters">
            <BlankTip />
            <Caption />
            <StandaloneOnly>true</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 Application with Date As At</List>
          </Parameter>
        </Parameters>
      </ISParameterDefs>
    </Parameters>
  </finDocument>