Article Details
Id: | 11666 |
Product: | finPOWER Connect |
Type: | FIX |
Version: | 2.00.02 |
Opened: | 13/01/2014 |
Closed: | 20/01/2014 |
Released: | 05/02/2014 |
Job: | J012723 |
Documents; Script type Documents do not retain the value of the 'Supports Batch Print' option
Script type Documents do not retain the value of the 'Supports Batch Print' option when saved.
This is necessary when using a Script type Document to generate an export file, e.g., to send to a publishing house.
The following sample Document Script will generate a made-up file format using the Script's 'Publish' event:
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 FileWriter As ISFileWriter
Dim LogPublishBatch As finLogPublishBatch
Dim LogPublishBatchItem As finLogPublishBatchItem
' Assume Success
Main = True
' Handle Events
Select Case eventId
Case "Publish"
' Script Document is being published. If this is an Ad-Hoc publish then source will be Nothing otherwise it will be a finLogPublishBatch object
LogPublishBatch = DirectCast(source, finLogPublishBatch)
' Write Header
FileWriter = finBL.Runtime.CreateFileWriter()
If FileWriter.Open("c:\docbatch.txt", False) Then
FileWriter.WriteLine("#Header: " & LogPublishBatch.Count & " items")
Else
Main = False
End If
' Write Lines
If Main Then
For Each LogPublishBatchItem In LogPublishBatch
If FileWriter.WriteLine(String.Format("{0}|{1}|{2}", LogPublishBatchItem.DocumentId, LogPublishBatchItem.Id, LogPublishBatchItem.Name)) Then
' Success
LogPublishBatchItem.PublishSuccess = True
LogPublishBatchItem.PublishDocumentFileName = "c:\docbatch.txt"
Else
' Failure
Main = False
LogPublishBatchItem.PublishError = finBL.Error.Message(True, True)
Exit For
End If
Next
End If
' Write Footer
If Main Then
Main = FileWriter.WriteLine("#Footer")
End If
' Finalise
If FileWriter.IsOpen Then FileWriter.Close()
End Select
End Function