×
Menu
Index

9.1.4. ChronoBatch

 
The ChronoBatch object gives access to the batch that is open: its documents, document types, the processing chain, grids (xgrid), labels, batch fields and the Enterprise status.
It is available in every script that runs with a batch open (all the job, document and field events). In stand-alone scripts you get a batch with ChronoApp.CreateBatch or ChronoApp.GetCurrentBatch.
 
Methods
Returns
Method
Description
short
AddClassificatorAndTag
(string Trigger, string Class, string Logic, string type, string tag)
Adds a class and a tag to a classifier trigger. Logic: AND or OR; type: MUSTHAVE or MUSTNOTHAVE.
short
AddIntellitag
(string ListName, string Tag, string SearchValue, string SearchValueRegEx = "", short TagIsRegEx = 0, short Fuzzy = -1, string DocumentType = "", string MasterKey = "", string EntityID = "", string UserVal1 = "", string UserVal2 = "", string UserVal3 = "")
Adds an Intelli-Tag to a list: Tag is the text to search for and SearchValue the value or search macro (%NEARESTCODE%...). Optional: SearchValueRegEx (regular expression used by the macro), TagIsRegEx (1 if Tag is a regular expression), Fuzzy (tolerance 0-5, -1 = default), DocumentType and MasterKey (scope), EntityID and UserVal1..3. Returns 1 if added, -1 if it already exists, 0 on error or if the list does not exist.
short
AddLabel
(string tag_name)
Adds a label (batch labeling) to the batch by name. Returns 1 if added.
long
AddNewDocument
(string file)
Adds a new document from a file
Parameters
file (string): File to add
Returns: 1 = True, 0 = False
short
AI_AssistantRebuild
(string type, string field)
Rebuilds the vector indexes of the AI Assistants of the job. type: intellitags, helplists or all; field: the field name or all.
void
CancelProcess
()
Cancel current batch processing
short
CloseBatch
()
Closes and saves the batch.
short
DeleteAllDocuments
()
Empty the Batch
Returns: 1 = True, 0 = False
Example
Set batch = ChronoApp.GetCurrentBatch
Dim r
r = batch.DeleteAllDocuments
'Or
r = ChronoBatch.DeleteAllDocuments
short
DeleteBatch
()
Deletes the batch and all its documents.
short
DeleteDocument
(short numdoc)
Deletes a single document
Returns: 1 = True, 0 = False
short
DeleteDocumentType
(string documenTypeName)
Deletes a document type of the job by name. Returns 1 if deleted.
object
DuplicateDocument
(object doc, short CopyFields = 0, short CopyXgrid = 0)
Creates a copy of a document in the batch and returns the new document. CopyFields=1 copies the field values and CopyXgrid=1 the grid rows.
string
ENT_geturl
(string code = "batch_index")
Returns the URL of the batch in the ChronoScan Enterprise web client (code: batch_index by default) to include it, for example, in a notification e-mail.
short
EntAddToEventLog
(string description)
Since v1.0.2.95
It Adds a record to the event log in an enterprise app.
Parameters
description (string): The description to log
ChronoScan Enterprise only.
Example
ChronoBatch.EntAddToEventLog("description here")
short
ExecuteBarcode
()
Executes the barcode configurations on all documents/pages.
short
ExecuteInputModule
(string modname, string modparams)
Executes the specified input module
Parameters
modname (string)
image_files (import image files) - options:
directory = c:\temp
extensions = *.pdf | onlythisfile.pdf | *.pdf;*.pdfx
finddirs = true|false
textread = true|false
maxfiles =
pagestoextract =
extracmode = 0 (images) | 1 (convert to image)
resolution = 96|120|150|200|300|400|600
colortype = 0 (black and white) | 1 (color)
splitonfile = true|false
splitondir = true|false
orientateauto = true|false
deleteonimport = true|false
renameimportfile = sav
movetofolder = <c:\process_folder> or <\process_folder>
for_fast_text_processing = 1 (speed up text extraction, warning: setting this parameter to 1 means that image quality will be lower)
debug = 1 (allows to view the import options before import)
pdf_files (import PDF files with text extraction and image conversion) - options:
directory = c:\temp
filename = *
extension = *
finddirs = true|false
maxfiles =
splitonfile = true|false
splitondir = true|false
importfromlastfile = true|false
deleteonimport = true|false
renameimportfile = sav
movetofolder = <c:\process_folder> or <\process_folder>
debug = 1 (allows to view the import options before import)
modparams (string): ConfigName#parameter=value#parameter=value
Returns: 1 = True, 0 = False
Example
ChronoBatch.ExecuteInputModule "pdf_files", "ConfigName#directory=c:\temp#filename=*#finddirs=true..."
short
ExecuteProcess
(string operations)
Runs a processing chain on the batch. Returns 1 on success.
Parameters
operations (string): Use ";" to execute more than one operation at once (ex: DESKEW;OCR). If empty will use the configured options on the Batch.
Allowed values: CROP, DESKEW, OCR, PRETRIGGERS, TYPEDETECT, FIELDREAD, XGRIDREAD, PATTERNREAD, EXPORTBATCH, BEEP, SENDMAIL
Returns: 1 = True, 0 = False
Example
Dim res
res = ChronoBatch.ExecuteProcess("DESKEW;OCR;SENDMAIL")
short
GetBatchFieldCount
()
Returns the number of batch fields defined in the job.
string
GetBatchFieldName
(short index)
Returns the name of the batch field at the given index (0-based).
string
GetBatchFieldValidateMessage
(string FieldName)
Returns the validation message of a batch field (empty if it is valid).
short
GetBatchFieldValidateStatus
(string FieldName)
Returns the validation status of a batch field (1 = valid, 0 = invalid).
string
GetBatchFieldValue
(string FieldName)
Returns the value of a batch field (batch fields have one value per batch and are defined in the job).
string
GetConversionModule_File
(short item, string ConvModule)
Returns the file generated by specific conversion module
Example: see example 1 at the end of this page.
short
GetConversionModule_FileCount
(string ConvModule)
Returns the number of files generated by specific conversion module
Example: see example 1 at the end of this page.
string
GetDateCreated
()
Returns Batch date creation
Returns: Batch date creation
Example
Dim date
date = ChronoBatch.GetDateCreated()
string
GetDateUpdated
()
Returns Batch update date
Returns: Batch update date
Example
Dim date
date = ChronoBatch.GetDateUpdated()
long
GetDocCount
()
Returns the number of documents
Returns: Number of documents of the batch
Example
Dim numdocs
numdocs = ChronoBatch.GetDocCount()
long
GetDocCountStatus
(short status)
Returns the number of documents with a specific status.
Parameters
status (short): 0 = validated
1 = error
Returns: Number of documents
object
GetDocument
(short item)
Returns the ChronoDocument object of a document of the batch (item = document number, 0-based).
Parameters
item (short): Document number
Returns: ChronoDocument (https://chronoscan.org/doc/chronodocument.htm)
string
GetEntityDescription
()
Returns the Batch Entity Description
string
GetEntityID
()
Returns the Batch Entity ID
string
GetEntityName
()
Returns the Batch Entity Name
string
GetEntStatus
()
Gets the batch status for an enterprise batch
Returns: unknown, increation, created, pre_class, reprocess, processed, post_class, configured, corrected, exported, export_error_status, archived, parked, processing_error, ready_to_export, waiting_external_actions
ChronoScan Enterprise only.
Example
dim r
r = ChronoBatch.GetEntStatus()
msgbox "status is: " & status
short
GetExportStatus
()
Returns the export status
Returns: 0 = not exported, 1 = exported ok, 2 = not exported because of not validated documents, 3 = error exporting, 4 = export canceled
Example
Dim res
res = ChronoBatch.GetExportStatus()
string
GetJobName
()
Returns job name
Returns: Job name
Example
Dim jobname
jobname = ChronoBatch.GetJobName()
variant
GetLabels
()
Returns an array with the names of the labels of the batch.
short
GetLastInputCount
()
Returns the number of documents generated by last scan/import process
Returns: Number of documents
Example
Dim red
res = ChronoBatch.GetLastInputCount()
string
GetName
()
Returns batch name
Returns: Batch name
Example
Dim batchname
batchname = ChronoBatch.GetName()
string
GetOcrText
()
NOT IMPLEMENTED: this method always returns an empty string. Use ChronoDocument.GetFullOcr instead.
string
GetOutModule_ConfigValue
(string OutModuleName, string itemName)
Returns a configuration value (itemName) of an output module of the job (OutModuleName), for example a destination folder.
object
GetOutModule_MFilesServerApplication
(string OutName, short cacheconnection = 0)
Returns the M-Files server application object (M-Files COM API) of an M-Files export module of the job, so the script can use the M-Files API with the same connection.
Parameters
targetDocNumber (String ): M-Files export module configuration
Example
Set oServerApp = Batch.GetOutModule_MFilesServerApplication("M-FILES")
object
GetSelectedDocument
()
Since v1.0.2.85
Returns first selected found ChronoDocument object
Returns: ChronoDocument: object (https://chronoscan.org/doc/chronodocument.htm)
Example
Set doc = ChronoBatch.getSelectedDocument()
string
GetSystemField
(short item, string FieldName)
Returns the value of a specific system row/field
Parameters
item (short): Document number
FieldName (string): System field name
Returns: System field value
Example: see example 2 at the end of this page.
string
GetUserField
(short item, string FieldName)
Returns the value of a specific row/field
Parameters
item (short): Document number
FieldName (string): Field name
Returns: User field value
Example
Dim val
val = ChronoBatch.GetUserField(docnumber, fieldName)
string
GetVariableValue
(string varname)
Returns a ChronoScan variable, it includes variables related with the batch
Parameters
varname (string): Requested variable to ChronoScan, for example "station_id". You can see a complete variable list in the variables wizard window of ChronoScan.
Returns: Value for the selected ChronoScan variable.
string
GetXgridColumnValue
(short item, short GridPanel, short row, short col)
Return the value of a specific capture grid field by column number
Parameters
item (short): Document number
GridPanel (short)
Allowed values: 1, 2, 3, 4
row (short): Row number (0 based)
col (short): Column number (0 based)
Returns: Capture grid field
short
GetXgridFieldBitmap
(short item, short GridPanel, short row, string FieldName, string bmpFile)
Save the zone bitmap of a specific capture grid field to a file
Parameters
docNumber (short): Document number
gridNumber (short)
Allowed values: 1, 2, 3, 4
gridRowNumber (short): Row number (0 based)
fieldName (string): Column number (0 based)
Returns: 1 = True, 0 = False
Example: see example 2 at the end of this page.
string
GetXgridFieldValue
(short item, short GridPanel, short row, string FieldName)
Returns the value of a specific capture grid field
Parameters
item (short): Document number
GridPanel (short)
Allowed values: 1, 2, 3, 4
row (short): Row number (0 based)
FieldName (string): Field name
Returns: Capture grid field
Example: see example 2 at the end of this page.
short
GetXgridLastEdited
()
Returns the number of last edited capture grid, This function can be used in OnXGridValueChanged event
Returns: 1, 2, 3, 4
string
GetXgridLastEditedField
(short GridPanel)
Return the name of last capture grid edited field, This function can be used in OnXGridValueChanged event
Parameters
GridPanel (short)
Allowed values: 1, 2, 3, 4
Returns: Name of the field
short
GetXgridRowCount
(short item, short GridPanel)
Return the number of records of a specific capture grid
Parameters
item (short): Document number (0 based)
GridPanel (short)
Allowed values: 1, 2, 3, 4
Returns: Number of rows
Example: see example 2 at the end of this page.
short
HasLabel
(string tag_name)
Returns 1 if the batch has the given label.
short
IgnoreDocument
(short doc, short mode = -1)
Ignores/ unignores a specific document
Parameters
doc (short): (1 based)
mode (short)
Allowed values: 0: Set as not ingored, 1: Ignore
Returns: 1 = True, 0 = False
Example
'Ignore a document
dim r
r = ChronoBatch.IgnoreDocument(1, 1)
short
IsDocumentIgnored
(short doc)
Tells us if a specific document is ignored
Parameters
doc (short): (1 based)
Returns: 1 = True, 0 = False
Example
dim r
r = ChronoBatch.IgnoreDocument(1)
short
IsValidated
(short item)
Return whether a document is validated
Parameters
item (short): Document number (0 based)
Returns: 1 = True, 0 = False
short
LinkDocumentTypeMasterkey
(string documenType, string masterkey)
Links a document type to a masterkey (masterkey setups). Returns 1 on success.
string
MergeDocuments
(short document1, short document2)
Merge two documents
Parameters
document1 (short): Target document number
document2 (short): Document number to merge
Returns: 1 = True, 0 = False
Example: see example 3 at the end of this page.
short
RemoveLabel
(string tag_name)
Removes a label from the batch by name. Returns 1 if removed.
short
Save
(short syncronizedb = 1)
Save Changes on the Batch
Parameters
syncronizedb (short) optional: default (1) synchronize the data in the database (ENT)
Returns: 1 = True, 0 = False
short
SetBatchFieldValue
(string FieldName, string Value)
Sets the value of a batch field; the field must exist in the job. The field is validated again and the form is refreshed. Returns 1 on success.
short
SetEntityID
(string entityID)
Sets an entity to a batch
Parameters
entityID (string): new entity ID
Returns: 0 = false, 1 = true
Example
Dim entityID
entityID = 12
res = ChronoBatch.SetEntityID(entityID)
short
SetEntStatus
(string newstatus)
Sets the batch status to an enterprise batch
Parameters
newstatus (string)
Allowed values: unknown, increation, created, pre_class, reprocess, processed, post_class, configured, corrected, exported, export_error_status, archived, parked, processing_error, ready_to_export, waiting_external_actions
Returns: 1 = True, 0 = False
ChronoScan Enterprise only.
Example
dim r
r = ChronoBatch.SetEntStatus("created")
short
SetExportStatus
(short newstatus)
Sets the export status
Parameters
newstatus (short): 0 = not exported
1 = exported ok
2 = not exported because of not validated documents
3 = error exporting
4 = export canceled
Returns: 0 = false, 1 = true
Example
'Set a batch status as "exported without errors"
Dim res
res = ChronoBatch.SetExportStatus(1)
short
SetUserField
(short item, string FieldName, string Value)
Update Field value of a specific row/field
Parameters:
Short document number
String Field name
String new value
Sample: Executing vbs script before/after export
short
UnLinkDocumentTypeMasterkey
(string documenType, string masterkey, short deleteTypeWhenNoLinks)
Removes the link between a document type and a masterkey; deleteTypeWhenNoLinks=1 deletes the type when no masterkey is linked to it any more.
short
ValidateBatchFields
()
Validates all the batch fields (required, validation mask and type). Returns 1 if all of them are valid.
 
Examples
Example 1 (GetConversionModule_File, GetConversionModule_FileCount)
Set Batch = ChronoApp.GetCurrentBatch
 
Dim NumDocs
NumDocs=Batch.GetDocCount
 
'navigating records
For i = 0 To NumDocs-1
        If (Batch.IsValidated(i)) Then
            MsgBox "Document Subject: "+Batch.GetUserField( i, "Subject")
            MsgBox "Source file: "+Batch.GetUserField( i, "SrcDoc")
'Update Field "Export date" to current date
            Call Batch.SetUserField(i, "Export date", Date)
 
'navigate each page
 Set Doc = Batch.GetDocument (i)
            numpages=Doc.get_page_count()
            MsgBox numpages & " pages"
            For page = 1 To numpages
                'obtain source page file
                MsgBox Doc.get_page_field_value (page, "SrcFile")
            Next
 
 
        End If
Next
 
 
Dim NumExpFiles
NumExpFiles=Batch.GetConversionModule_FileCount("chronoscan pdf text conversion")
 
'navigating generated Documents
If NumExpFiles >0 Then
        For i = 0 To NumExpFiles-1
Dim file
            file=Batch.GetConversionModule_File(i,"chronoscan pdf text conversion")
            MsgBox "Exported file: "+file
        Next
End If
 
Example 2 (GetSystemField, GetXgridFieldBitmap, GetXgridFieldValue, GetXgridRowCount)
Function GetPath(file)
        Dim objFSO, objFile, objFolder
        Dim intIndex
 
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objFile = objFSO.GetFile(file)
        Set objFolder = objFile.ParentFolder
 
        GetPath=objFolder.Path
End Function
 
 
 
 
Set Batch = ChronoApp.GetCurrentBatch
 
Dim NumDocs
NumDocs=Batch.GetDocCount
 
'navigating records
For numDoc = 0 To NumDocs-1
        If (Batch.IsValidated(numDoc)) Then
            'we need the path of a file generated by xml export module
     'when the document has exported, the system field "expinfo.XML Report.File Sysstem_1" is filled with the generated xml
     'we can use it to extract the path to save the bmp in the same directory
            Dim strPath
            strPath = Batch.GetSystemField (numDoc, "expinfo.XML Report.File System_1")'first part of a result bmp
            strPath=GetPath(strPath)'we need Only file path
            Dim Barcode1
            Barcode1 = Batch.GetUserField( numDoc, "Barcode 1")'Second part of a result bmp
            'MsgBox "Document Barcode1: "+Barcode1
 
 
 
            Dim tableNumber, numRows
            tableNumber=1'we are using table 1
 
            numRows=Batch.GetXgridRowCount (numDoc,tableNumber)
            MsgBox "Total Records in xgrid table: "  + CStr(numRows)
 
            'navigating xgrid table records
            Dim row
            For row = 0 To numRows-1
 
                        'Extract field "ID" from xgrid For compose export bmp file
                        Dim strIndexValue
 
 
                        strIndexValue=Batch.GetXgridFieldValue (numDoc,tableNumber, row, "Index")'Third part of a result bmp
 
                        Dim strSaveFile
                        strSaveFile=strPath+""+Barcode1+"_"+strIndexValue+".bmp"
                        'MsgBox "File to save: "+strSaveFile
                        If Batch.GetXgridFieldBitmap (numDoc,tableNumber, row, "Signature", strSaveFile) Then
                        Else
                           MsgBox "An Error occurred saving file: " +strSaveFile
                           Exit For
                    End If
            Next
        End If
Next
 
Example 3 (MergeDocuments)
'Get current batch
Set Batch=ChronoApp.GetCurrentBatch
'Get document count
Dim NumDocs
NumDocs = Batch.GetDocCount
docpos_1 = 0
 
'Loop the Batch
Do Until docpos_1 >= NumDocs
        Set document1 = Batch.GetDocument(docpos_1)
        barcode1=document1.get_field_value("Barcode Read")
        'Get next document and search for repeated values
        docpos_2=docpos_1+1
        Do Until docpos_2 >= NumDocs 'start from current document
                  Set document2 = Batch.GetDocument(docpos_2)
                  barcode2=document2.get_field_value("Barcode Read")
                  If barcode1=barcode2 Then
                      'If the barcode values match, merge the documents
                      Batch.MergeDocuments docpos_1, docpos_2
                       NumDocs=NumDocs-1
          Else
                      docpos_2=docpos_2+1
              End If
    Loop
    docpos_1=docpos_1+1
Loop