' SummaryPage2_ElectronicSignatureSummary_AdobeSign
Option Explicit On
Option Strict On

' #################################################################
' Adobe Sign Electronic Signature Summary Page Script
'
' Version: 2.06  (20/03/2023)
'
' Usage: Log Forms, Pending Service Request wizard
' #################################################################
' Version        Date  User     Job       Description
' -------  ----------  -------  --------  -------------------------
'    2.03  01/09/2016  ISS
'    2.04  04/11/2021  ISS      J027713   Updated obsoleted functions
'    2.05  15/07/2022  ISS      J029160   Updated theme
'    2.06  20/03/2023  ISS      J027938   Application shortcut not visible on web pages
' #################################################################

' Constants
Const TestMode As Boolean = False

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

  Dim ServiceLogs As ISServiceLogs

  ' Assume Success
  Main = True

  ' Get Constants
  With ScriptInfo.Constants
  End With

  ' Get Service Logs
  Try
    Main = finBL.ElectronicSignature.GetServiceLogs(CInt(source), ServiceLogs)
  Catch ex As Exception
    Main = False
    finBL.Error.ErrorBeginFromException(ex)
  End Try
  If Main Then
    If ServiceLogs.Count = 0 Then
      Main = False
      finBL.Error.ErrorBegin("Invalid Service Log for an Electronic Signature.")
    ElseIf ServiceLogs(0).RequestStatus <> iseAuditLogStatus.Success Then
      Main = False
      finBL.Error.ErrorBegin("Invalid Service Log. Initial Request was not successful.")
    Else
      Select Case TypeName(ServiceLogs(0).ExResponse)
        Case "ISElectronicSignatureResponse_AdobeSign_AgreementSend"
        Case "ISElectronicSignatureResponse_AdobeSign_AgreementStatus"
        Case Else
          finBL.Error.ErrorBegin("Invalid Service Log. Request is not for an Adobe Sign Electronic Signature.")
          Return False
      End Select
    End If
  End If

  ' Handle Events
  If Main Then
    Select Case eventId
      Case ""
        ' Main event, i.e., return main page content
        Main = CreatePage(ServiceLogs, text)
    End Select
  End If

End Function

Private Function CreatePage(serviceLogs As ISServiceLogs,
                            ByRef html As String) As Boolean

  Dim HtmlSummaryPage2StringBuilder As finHtmlSummaryPage2StringBuilder
  Dim Response As ISElectronicSignatureResponse
  Dim Success As Boolean

  ' Assume Success
  Success = True

  ' Initialise ByRef
  html = ""

  ' Get Initial Response
  Response = DirectCast(serviceLogs(0).ExResponse, ISElectronicSignatureResponse)

  ' Initialise HTML
  HtmlSummaryPage2StringBuilder = finBL.CreateHtmlSummaryPage2StringBuilder()
  With HtmlSummaryPage2StringBuilder
    ' Initialise
    ' Note: Embed images (will also embed CSS) since we want to be able to easily produce a PDF document
    .Initialise(ScriptInfo, False, True)

    ' Display Test watermark
    If serviceLogs(0).TestMode Then .Watermark = "Test Mode"

    ' Begin HTML Header
    .HtmlHeaderBegin(String.Format("{0} {1}", Response.ServiceName, Response.ProductId), isefinSummaryPageStyle.ServiceReport)

    ' Theme
    '.HtmlHeaderInsertServiceReportTheme("#001533", "#6BABFF", "", "#CED9E5")
    .HtmlHeaderInsertServiceReportTheme("#333333", "#b9b9b9", "", "#ececec")

    ' Intersoft PDF Options (including style tweaks)
    .HtmlHeaderInsertPdfGenerationHints("A4", "Portrait", 880, "1.5cm", "1.5cm", "1cm", "1cm", "font-size:0.9em")

    ' Finalise HTML Header
    .HtmlHeaderEnd()
  End With

  Select Case TypeName(Response)
    Case "ISElectronicSignatureResponse_AdobeSign_AgreementSend"
      CreatePage_AgreementSend(HtmlSummaryPage2StringBuilder, DirectCast(Response, ISElectronicSignatureResponse_AdobeSign_AgreementSend), serviceLogs)

    Case "ISElectronicSignatureResponse_AdobeSign_AgreementStatus"
      ' Created from an existing Electronic Signature
      CreatePage_AgreementStatus(HtmlSummaryPage2StringBuilder, DirectCast(Response, ISElectronicSignatureResponse_AdobeSign_AgreementStatus), serviceLogs)

    Case Else
      Success = False
      finBL.Error.ErrorBeginFormat("Unexpected Response Type '{0}'.", TypeName(Response))
  End Select

  If Success Then
    ' Disclaimer
    HtmlSummaryPage2StringBuilder.AppendLine("{{disclaimer|This report was produced by finPOWER Connect version " & finBL.VersionMajorMinorBuild & " using information retrieved from the " & Response.ServiceName & " service on " & finBL.FormatDateTime(Response.RequestDate, True, True, True) &"}}")

    ' Finalise HTML
    HtmlSummaryPage2StringBuilder.HtmlFinalise()

    ' Resolve Templates
    html = HtmlSummaryPage2StringBuilder.ToString(True)
  End If

  Return Success

End Function

Private Sub CreatePage_AgreementSend(htmlSummaryPage2StringBuilder As finHtmlSummaryPage2StringBuilder,
                                     response_AgreementSend As ISElectronicSignatureResponse_AdobeSign_AgreementSend,
                                     serviceLogs As ISServiceLogs)

  With htmlSummaryPage2StringBuilder
    ' Heading
    .AppendH1(response_AgreementSend.Request.DocumentCreationInfo.Name)
    .AppendH2(response_AgreementSend.ServiceName)

    .SummaryTablesAppend(Me.AdobeSign_Actions(serviceLogs))
    .SummaryTablesAppend(Me.AdobeSign_CurrentStatus(serviceLogs))
    .SummaryTablesAppend(Me.AdobeSign_OriginalDetails(response_AgreementSend))
    .SummaryTablesAppend(Me.AdobeSign_History(serviceLogs))
  End With

End Sub

Private Sub CreatePage_AgreementStatus(htmlSummaryPage2StringBuilder As finHtmlSummaryPage2StringBuilder,
                                       response_AgreementStatus As ISElectronicSignatureResponse_AdobeSign_AgreementStatus,
                                       serviceLogs As ISServiceLogs)

  With htmlSummaryPage2StringBuilder
    ' Heading
    .AppendH1(response_AgreementStatus.Name)
    .AppendH2(response_AgreementStatus.ServiceName)

    .SummaryTablesAppend(Me.AdobeSign_Actions(serviceLogs))
    .SummaryTablesAppend(Me.AdobeSign_CurrentStatus(serviceLogs))
    .SummaryTablesAppend(Me.AdobeSign_History(serviceLogs))
  End With

End Sub

Private Function AdobeSign_Actions(serviceLogs As ISServiceLogs) As ISSummaryTables

  Dim Response_AgreementStatus As ISElectronicSignatureResponse_AdobeSign_AgreementStatus
  Dim ServiceLog As ISServiceLog
  Dim ServiceLog_AgreementGetCombinedDocument As ISServiceLog
  Dim strTemp As String
  Dim SummaryTable As ISSummaryTable
  Dim SummaryTables As ISSummaryTables

  ' Initialise
  SummaryTables = finBL.CreateSummaryTables()

  ' Get Downloaded Document
  For Each ServiceLog In serviceLogs
    Select Case TypeName(ServiceLog.ExResponse)
      Case "ISElectronicSignatureResponse_AdobeSign_AgreementGetCombinedDocument"
        ServiceLog_AgreementGetCombinedDocument = ServiceLog
      Case "ISElectronicSignatureResponse_AdobeSign_AgreementStatus"
        Response_AgreementStatus = DirectCast(ServiceLog.ExResponse, ISElectronicSignatureResponse_AdobeSign_AgreementStatus)
    End Select
  Next

  ' Create Summary Table
  SummaryTable = SummaryTables.CreateSummaryTableBlank("", "", "", 3)

  ' Add Actions
  With SummaryTable.Actions
    Select Case serviceLogs(0).ResponseStatus
      Case iseServiceLogResponseStatus.InProgress
        ' Add Action to Update Status
        ' Warning if doing too often
        If finBL.TimeZoneFunctions.GetCurrentUtcDateTime() > serviceLogs(0).ResponseNextCheckUtcDate Then
          strTemp = ""
        Else
          strTemp = String.format(" !!WARNING: Not due to be re-checked until {0}!!", finBL.FormatDateTimeLong(serviceLogs(0).ResponseNextCheckDate))
        End If
        .AddApplicationShortcutUrl("UpdateStatus", "Update Status", String.Format("app://global?type=ElectronicSignature.UpdateStatus&serviceLogPk=" & serviceLogs(0).Pk), True).ShowInWebInterfaces = True

        ' Add Action to Send Reminder
        .AddApplicationShortcutUrl("SendReminder", "Send Reminder", String.Format("app://global?type=ElectronicSignature.SendReminder&serviceLogPk=" & serviceLogs(0).Pk), True).ShowInWebInterfaces = True

        ' Add Action to Cancel Electronic Signature
        .AddApplicationShortcutUrl("Cancel", "Cancel", String.Format("app://global?type=ElectronicSignature.Cancel&serviceLogPk=" & serviceLogs(0).Pk), True).ShowInWebInterfaces = True

      Case Else
        ' Add Action to Get/ View Document
        If ServiceLog_AgreementGetCombinedDocument Is Nothing Then
          If Response_AgreementStatus IsNot Nothing AndAlso Response_AgreementStatus.StatusComplete Then
            .AddApplicationShortcutUrl("GetDocument", "Get Document", String.Format("app://global?type=ElectronicSignature.GetDocuments&serviceLogPk=" & serviceLogs(0).Pk), True).ShowInWebInterfaces = True
          End If
        Else
          .AddApplicationShortcutUrl("OpenDocument", "View Document", String.Format("app://global?type=ElectronicSignature.OpenDocument&serviceLogPk=" & ServiceLog_AgreementGetCombinedDocument.Pk), True).ShowInWebInterfaces = True
        End If
    End Select
  End With

  ' Add Summary Table
  If SummaryTable.Actions.Count <> 0 Then SummaryTables.Add("Actions", SummaryTable)

  Return SummaryTables

End Function

Private Function AdobeSign_CurrentStatus(serviceLogs As ISServiceLogs) As ISSummaryTables

  Dim AlternateParticipant As ISElectronicSignatureResponse_AdobeSign_Participant
  Dim AlternateParticipantSet As ISElectronicSignatureResponse_AdobeSign_ParticipantSet
  Dim FirstInSet As Boolean
  Dim HistoryEvent As ISElectronicSignatureResponse_AdobeSign_DocumentHistoryEvent
  Dim NextParticipant As ISElectronicSignatureResponse_AdobeSign_NextParticipant
  Dim NextParticipantSet As ISElectronicSignatureResponse_AdobeSign_NextParticipantSet
  Dim Participant As ISElectronicSignatureResponse_AdobeSign_Participant
  Dim ParticipantSet As ISElectronicSignatureResponse_AdobeSign_ParticipantSet
  Dim Response_AgreementCancel As ISElectronicSignatureResponse_AdobeSign_AgreementCancel
  Dim Response_AgreementStatus As ISElectronicSignatureResponse_AdobeSign_AgreementStatus
  Dim ServiceLog As ISServiceLog
  Dim SummaryTable As ISSummaryTable
  Dim SummaryTables As ISSummaryTables

  ' Initialise
  SummaryTables = finBL.CreateSummaryTables()

  ' Get Latest Response
  For Each ServiceLog In serviceLogs
    Select Case TypeName(ServiceLog.ExResponse)
      Case "ISElectronicSignatureResponse_AdobeSign_AgreementCancel"
        Response_AgreementCancel = DirectCast(ServiceLog.ExResponse, ISElectronicSignatureResponse_AdobeSign_AgreementCancel)
        If Response_AgreementCancel.Result <> iseElectronicSignatures_AdobeCancelDocumentResult.Cancelled Then Response_AgreementCancel = Nothing
      Case "ISElectronicSignatureResponse_AdobeSign_AgreementStatus"
        Response_AgreementStatus = DirectCast(ServiceLog.ExResponse, ISElectronicSignatureResponse_AdobeSign_AgreementStatus)
    End Select
  Next

  If Response_AgreementStatus Is Nothing Then
    SummaryTables.AddSummaryTableBlank("Main", "Current Status", "{{info|Click the 'Update Status' button in the Actions section to update the Status.}}")
  Else
    ' Agreement
    SummaryTable = SummaryTables.CreateSummaryTableInformation("Current Status", "CurrentStatus", 2,,, TestMode)
    With SummaryTable
      .AddRowCaptionDateTimeWithTimeZone("Retrieved:", Response_AgreementStatus.RequestDate, "")
      If Response_AgreementStatus.StatusTerminal Then
        If Response_AgreementStatus.StatusComplete Then
          .AddRowCaptionWiki("Status:", String.Format("**++{0} (Closed)++**", Response_AgreementStatus.StatusText), True, iseSummaryTableCellClass.Highlight2)
        Else
          .AddRowCaptionWiki("Status:", String.Format("**!!{0} (Closed)!!**", Response_AgreementStatus.StatusText), True, iseSummaryTableCellClass.Highlight2)
        End If
        If Response_AgreementCancel IsNot Nothing Then
          .AddRowCaptionWiki("Cancelled Result:", String.Format("**!!{0}!!**", Response_AgreementCancel.ResultRaw), True, iseSummaryTableCellClass.Highlight2)
          .AddRowCaptionText("Comment:", Response_AgreementCancel.Request.Comment, False)
          .AddRowCaptionTick("Notify Signers:", Response_AgreementCancel.Request.NotifySigner)
        End If
      Else
        .AddRowCaptionText("Status:", Response_AgreementStatus.StatusText, True)
        If Response_AgreementStatus.ExpirationUtcDate = Nothing Then
          ' No expiry
        ElseIf finBL.TimeZoneFunctions.GetCurrentUtcDateTime > Response_AgreementStatus.ExpirationUtcDate Then
          ' Expired
          .AddRowCaptionWiki("Expiry:", String.Format("**!!Expired on {0}!!**", finBL.FormatDateTimeLong(Response_AgreementStatus.ExpirationDate)))
        Else
          .AddRowCaptionWiki("Expiry:", String.Format("**{0}**", finBL.FormatDateTimeLong(Response_AgreementStatus.ExpirationDate)))
        End If
      End If
    End With
    SummaryTables.Add("CurrentStatus", SummaryTable)

    ' Participants
    SummaryTable = SummaryTables.CreateSummaryTableTabular("Participants", "Participants", 3, TestMode)
    With SummaryTable
      If Response_AgreementStatus.ParticipantSets.Count = 0 Then
        .TextBefore = "{{info|No Participant found.}}"
      Else
        ' Columns
        With .Columns
          .AddBoolean("Signed")
          .AddText("Role")
          .AddText("Status")
          .AddText("Name")
          .AddText("Company")
          .AddText("Title")
          .AddText("Email")
        End With

        For Each ParticipantSet In Response_AgreementStatus.ParticipantSets
          FirstInSet = True

          Select Case ParticipantSet.Status
            Case iseElectronicSignatures_AdobeUserAgreementStatus.NotYetVisible
            Case Else
              For Each Participant In ParticipantSet.Participants
                With .Rows.Add()
                  .BackgroundColour = ParticipantSet.StatusBackgroundColourHtml

                  With .Cells
                    If FirstInSet Then
                      Select Case ParticipantSet.Status
                        Case iseElectronicSignatures_AdobeUserAgreementStatus.Signed
                          .AddTick(True)
                        Case Else
                          .AddText("")
                      End Select
                      .AddText(ParticipantSet.Roles.ToCsvString())
                      .AddText(ParticipantSet.StatusText)
                    Else
                      .AddText("")
                      .AddText("")
                      .AddText("")
                    End If
                    .AddText(Participant.Name)
                    .AddText(Participant.Company)
                    .AddText(Participant.Title)
                    .AddText(Participant.Email)
                    If Participant.AlternateParticipants.Count <> 0 Then
                      For Each AlternateParticipantSet In Participant.AlternateParticipants
                        For Each AlternateParticipant In AlternateParticipantSet.Participants
                          With SummaryTable.Rows.Add().Cells
                            .AddText("")
                            .AddText(">> Alternate")
                            .AddText(AlternateParticipant.Name)
                            .AddText(AlternateParticipant.Company)
                            .AddText(AlternateParticipant.Title)
                            .AddText(AlternateParticipant.Email)
                          End With
                        Next
                      Next
                    End If
                  End With
                End With

                FirstInSet = False
              Next
          End Select
        Next
      End If
    End With
    SummaryTables.Add("Participants", SummaryTable)

    ' Next Participants
    If Response_AgreementStatus.NextParticipantSets.Count <> 0 Then
      SummaryTable = SummaryTables.CreateSummaryTableTabular("Next Participants", "NextParticipants", 3, TestMode)
      With SummaryTable
        ' Columns
        With .Columns
          .AddText("Waiting Since")
          .AddText("Name")
          .AddText("Email")
        End With

        For Each NextParticipantSet In Response_AgreementStatus.NextParticipantSets
          For Each NextParticipant In NextParticipantSet.NextParticipants
            With .Rows.Add().Cells
              .AddDateTime(NextParticipant.WaitingSinceDateTime, True, True)
              .AddText(NextParticipant.Name)
              .AddText(NextParticipant.Email)
            End With
          Next
        Next
      End With
      SummaryTables.Add("NextParticipants", SummaryTable)
    End If

    ' Events
    If Response_AgreementStatus.Events.Count <> 0 Then
      SummaryTable = SummaryTables.CreateSummaryTableTabular("Events", "Events", 3, TestMode)
      With SummaryTable
        ' Define Columns
        With .Columns
        .AddDateTime("Date")
        .AddText("Type")
        .AddText("Description")
        .AddText("Email")
        .AddText("IP Address")
        .AddText("Comment")
        End With

        ' Add Rows
        For Each HistoryEvent In Response_AgreementStatus.Events
          With .Rows.Add().Cells
            .AddDateTime(HistoryEvent.EventDateTime, True, True)
            .AddText(HistoryEvent.EventTypeText)
            .AddText(HistoryEvent.Description)
            .AddText(HistoryEvent.ActingUserEmail)
            .AddText(HistoryEvent.ActingUserIpAddress)
            If Len(HistoryEvent.Comment) = 0 Then
              .AddText("")
            Else
              Select Case HistoryEvent.EventType
                Case iseElectronicSignatures_AdobeAgreementEventType.WebIdentityAuthenticated
                  ' Normally a hyperlink to the Web Identity's website
                  Select Case UCase(Left(HistoryEvent.Comment, 7))
                    Case "HTTP://", "HTTPS:/"
                      With .AddText(HistoryEvent.Comment)
                        .HyperlinkSetExternal(HistoryEvent.Comment)
                      End With
                    Case Else
                      .AddText(HistoryEvent.Comment)
                  End Select

                Case Else
                  .AddText(HistoryEvent.Comment)
              End Select
            End If
          End With
        Next
      End With
      SummaryTables.Add("Events", SummaryTable)
    End If
  End If

  Return SummaryTables

End Function

Private Function AdobeSign_OriginalDetails(response_AgreementSend As ISElectronicSignatureResponse_AdobeSign_AgreementSend) As ISSummaryTables

  Dim FileInfo As ISElectronicSignatureRequest_AdobeSign_FileInfo
  Dim FirstInSet As Boolean
  Dim HasLibraryDocumentId As Boolean
  Dim RecipientInfo As ISElectronicSignatureRequest_AdobeSign_RecipientInfo
  Dim RecipientSetInfo As ISElectronicSignatureRequest_AdobeSign_RecipientSetInfo
  Dim SummaryTable As ISSummaryTable
  Dim SummaryTables As ISSummaryTables

  ' Initialise
  SummaryTables = finBL.CreateSummaryTables()

  ' Main
  SummaryTable = SummaryTables.CreateSummaryTableInformation("Original Document Details", "OriginalDocumentDetails", 2,,, TestMode)
  With SummaryTable
    .AddRowCaptionDateTimeWithTimeZone("Request Date:", response_AgreementSend.RequestDate, "")
    '.AddRowCaptionText("Agreement Id:", response_AgreementSend.AgreementId)
    .AddRowCaptionText("Name:", response_AgreementSend.Request.DocumentCreationInfo.Name, True)
    .AddRowCaptionText( "Message:", response_AgreementSend.Request.DocumentCreationInfo.Message, True)
    If response_AgreementSend.Request.DocumentCreationInfo.DaysUntilSigningDeadline <> 0 Then
      .AddRowCaptionInteger("Days to Expire:", response_AgreementSend.Request.DocumentCreationInfo.DaysUntilSigningDeadline)
    End If
    If response_AgreementSend.Expiration <> Nothing Then
      .AddRowCaptionDateTime("Expiration:", response_AgreementSend.Expiration)
    End If
    .AddRowCaptionText("CCs:", response_AgreementSend.request.DocumentCreationInfo.CCs.ToCsvString())
    .AddRowCaptionText("Signature Flow:", response_AgreementSend.Request.DocumentCreationInfo.SignatureFlowText)
    If Len(response_AgreementSend.request.DocumentCreationInfo.ExternalId.Id) <> 0 Then
      .AddRowCaptionText("External Info:", String.Format("{0} '{1}'", response_AgreementSend.Request.DocumentCreationInfo.ExternalId.Group, response_AgreementSend.Request.DocumentCreationInfo.ExternalId.Id))
    End If
  End With
  SummaryTables.Add("OriginalDocumentDetails", SummaryTable)

  ' Recipients
  SummaryTable = SummaryTables.CreateSummaryTableTabular("Recipients", "Recipients", 3, TestMode)
  With SummaryTable
    If response_AgreementSend.Request.DocumentCreationInfo.RecipientSetInfos.Count = 0 Then
      .TextBefore = "{{info|No Recipients defined.}}"
    Else
      ' Define Columns
      With .Columns
        .AddText("Client")
        .AddText("Role")
        .AddText("Email")
      End With

      ' Add Rows
      For Each RecipientSetInfo In response_AgreementSend.Request.DocumentCreationInfo.RecipientSetInfos
        FirstInSet=True
        For Each RecipientInfo In RecipientSetInfo.RecipientSetMemberInfos
          With .Rows.Add().Cells
            With .AddText(RecipientInfo.ClientId)
              If len(RecipientInfo.ClientId) <> 0 Then .HyperlinkSetFormShow("Clients", RecipientInfo.ClientId)
            End With
            If FirstInSet Then
              .AddText(RecipientSetInfo.RecipientRoleText)
            Else
              .AddText("")
            End If
            .AddText(RecipientInfo.Email)
          End With

          FirstInSet = False
        Next
      Next
    End If
  End With
  SummaryTables.Add("Signers", SummaryTable)

  ' Files
  SummaryTable = SummaryTables.CreateSummaryTableTabular("Files", "Files", 3, TestMode)
  With SummaryTable
    If response_AgreementSend.Request.DocumentCreationInfo.FileInfos.Count = 0 Then
      .TextBefore = "{{info|No Files defined.}}"
    Else
      ' Cache Values
      HasLibraryDocumentId = response_AgreementSend.Request.DocumentCreationInfo.FileInfos.HasLibraryDocumentId

      ' Define Columns
      With .Columns
        .AddText("Filename")
        If HasLibraryDocumentId Then .AddText("Library Filename")
      End With

      ' Add Rows
      For Each FileInfo In response_AgreementSend.Request.DocumentCreationInfo.FileInfos
        With .Rows.Add().Cells
          .AddText(finBL.Runtime.FileUtilities.GetFileName(FileInfo.FileName))
          If HasLibraryDocumentId Then .AddText(FileInfo.LibraryDocumentName)
        End With
      Next
    End If
  End With
  SummaryTables.Add("Files", SummaryTable)

  Return SummaryTables

End Function

Private Function AdobeSign_History(serviceLogs As ISServiceLogs) As ISSummaryTables

  Dim ServiceLog As ISServiceLog
  Dim SummaryTable As ISSummaryTable
  Dim SummaryTables As ISSummaryTables

  ' Initialise
  SummaryTables = finBL.CreateSummaryTables()

  SummaryTable = SummaryTables.CreateSummaryTableTabular("History", "", 2, TestMode)
  With SummaryTable
    ' Define Columns
    With .Columns
      .AddText("Service Log")
      .AddDateTime("Date")
      .AddText("User")
      .AddText("Type")
      .AddText("Status")
    End With

    ' Add Rows
    For Each ServiceLog In serviceLogs
      With .Rows.Add().Cells
        With .AddText(CStr(serviceLog.Pk))
          .HyperlinkSetApplicationShortcutUrl(String.Format("FormShow?form=ServiceLog&id={0}", ServiceLog.Pk))
        End With
        .AddDateTime(ServiceLog.CreatedDate, True, True)
        .AddText(finBL.Users.GetRecordCodeDescription(ServiceLog.CreatedUserPk, ""))
        .AddText(finBL.Runtime.TextUtilities.SplitWordsAtCapitals(ServiceLog.ProductId))
        .AddText(ServiceLog.RequestStatusText)
      End With
    Next
  End With
  SummaryTables.Add("History", SummaryTable)

  Return SummaryTables

End Function