<?xml version="1.0" encoding="utf-8"?><finScript version="1.00" exportedUtcDate="2011-01-27T19:58:06.5807760"><CreatedUtcDate>2010-12-22T20:55:51.9810000</CreatedUtcDate><CreatedUserId>Admin</CreatedUserId><UpdatedUtcDate>2011-01-27T19:57:42.3480000</UpdatedUtcDate><UpdatedUserId>Admin</UpdatedUserId><ScriptId>GLEXPORT</ScriptId><Description>GL Export sample</Description><ScriptType>ObjectEvents</ScriptType><Active>true</Active><AllowUI>false</AllowUI><Category /><ActionCategory /><AccountProcessesRunByDefault>false</AccountProcessesRunByDefault><Code>Option Explicit On

Public Function Main(ByVal eventId As String, ByRef eventHandled As Boolean, ByVal source As Object, ByVal sourceIndex As Integer, ByVal contextData1 As Object, ByVal contextData2 As Object, ByVal parameters As Object) As Boolean

  ' Parameters:
  '   eventId - The event to process
  '   eventHandled - Used to indicate that an event was handled by this Script so normal processing should be ignored (only applies to certain events)
  '   source - The Source object
  '   sourceIndex - The Source object's index, if applicable
  '   contextData1 - Context specific data
  '   contextData2 - Context specific data
  '   parameters - Other values passed to the Script

  Dim GlExport As finGlExport
  Dim GlBankTransaction As ISGlBankTransaction
  Dim GlBankTransactionAnalysisItem As ISGlBankTransactionAnalysisItem
  Dim GlJournal As ISGlJournal
  Dim Export As ISFileWriter
  Dim strTemp As String

  ' Assume Success
  Main = True

  ' Initialise
  GlExport = DirectCast(source, finGlExport)

  ' Handle Events
  Select Case eventId
    Case "ExportOpen"
      ' The Export is being opened. Only applicable to custom exports.

      ' Create Exporter and open the file
      Export = finBL.Runtime.CreateFileWriter()
      Main = Export.Open(GlExport.FileName)

      ' Write Custom Header
      If Main Then
        Main = Export.WriteLine("CustomHeader")
      End If

      ' Save Exporter to Tag property of GLExport so we can re-use it in ExportLine and ExportClose events
      GlExport.Tag = Export

    Case "ExportBankTransaction"
      ' A Bank Transaction is being exported. This can be modified if required.
      GlBankTransaction = DirectCast(contextData1, ISGlBankTransaction)

      ' Modify Bank Transaction
      GlBankTransaction.Comment &amp;= Trim(" - modified before exported!")

      ' Export Journal
      Select Case GLExport.ExportType
        Case iseGlExportType.Custom
          ' Get Exporter from Tag property
          Export = DirectCast(GlExport.Tag, ISFileWriter)

          ' Go through each Bank Tranasaction Item
          For Each GlBankTransactionAnalysisItem In GlBankTransaction.AnalysisItems
            ' Build Custom line
            With GlBankTransaction
              strTemp = finBL.Runtime.TextUtilities.CsvAppend("", "CustomBankTransaction")
              If .BankTransactionType = iseBankTransactionType.Deposit Then
                strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, "D")
              Else
                strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, "W")
              End If
              strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, .BankAccountId)
              strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, Format(.DateBank, "yyyyMMdd"))
              strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, .Reference)
              With GlBankTransactionAnalysisItem
                strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, .GlAccountId)
                strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, Format(.Value, "#########0.00"))
                strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, .Comment)
              End With
            End With

            ' Write Line
            If Not Export.WriteLine(strtemp) Then
              Main = False
              Exit For
            End If
          Next
      End Select

    Case "ExportJournalBegin"
      ' A set of double entry Journals is about to be exported. Use if a double entry header is required.
      GlJournal = DirectCast(contextData1, ISGlJournal)

    Case "ExportJournal"
      ' A Journal is being exported. This can be modified if required.
      GlJournal = DirectCast(contextData1, ISGlJournal)

      ' Modify Journal
      GlJournal.Notes &amp;= Trim(" - modified before exported!")

      ' Export Journal
      Select Case GLExport.ExportType
        Case iseGlExportType.Custom
          ' Get Exporter from Tag property
          Export = DirectCast(GlExport.Tag, ISFileWriter)

          ' Build Custom line
          strTemp = finBL.Runtime.TextUtilities.CsvAppend("", "CustomJournal")
          strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, "J")
          strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, GlJournal.GlAccountId)
          strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, Format(GlJournal.TransactionDate, "yyyyMMdd"))
          strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, GlJournal.Reference)
          strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, Format(GlJournal.Value, "#########0.00"))
          strTemp = finBL.Runtime.TextUtilities.CsvAppend(strTemp, GlJournal.Notes)

          ' Write Custom Line
          Main = Export.WriteLine(strtemp)

      End Select

    Case "ExportJournalEnd"
      ' A set of double entry Journals has been exported. Use if a double entry footer is required.

    Case "ExportCancel"
      ' The Export is being cancelled, use to close open files etc. Only applicable to custom exports.

      ' Get Exporter from Tag property
      Export = DirectCast(GlExport.Tag, ISFileWriter)

      ' Close
      Main = Export.Close()

    Case "ExportClose"
      ' The Export is being closed. Only applicable to custom exports.

      ' Get Exporter from Tag property
      Export = DirectCast(GlExport.Tag, ISFileWriter)

      ' Write Custom Footer
      Main = Export.WriteLine("CustomFooter")

      ' Close
      If Main Then
        Main = Export.Close()
      Else
        ' Must close anyway
        Export.Close()
      End If

  End Select

End Function</Code><Language>VisualBasic</Language><Notes /><PermissionKeyExecute /><RunWithoutPrompts>false</RunWithoutPrompts><ShowInAccountProcesses>false</ShowInAccountProcesses><ShowInMenu>None</ShowInMenu><ShowInTaskManager>false</ShowInTaskManager><SummaryPageHide>false</SummaryPageHide><TimeoutSeconds>60</TimeoutSeconds><TargetObjectType>GLExport</TargetObjectType><ParametersType>None</ParametersType></finScript>