| Back | Main view | Parent doc
Using and customizing IMiS/BatchScan from Lotus Notes client
IMPORTANT: Microsoft XML Parser 2.5 is required. It is shipped with Windows 2000 (or higher) or Internet Explorer 5.5 (or higher).
We introduced this feature in version 5.2. Main idea is to scan batch of documents that need to be linked to one Notes document. So this is different than using IMiS/Batchscan and IMiS/Avalanche, where we usually scan batch of documents of the same type and then link them to different Notes documents or even create Notes documents.
So if all documents from the batch should be linked in one Notes document than it would be appropriate if we can start IMiS/BatchScan from that Notes document. That is why we developed IMiS Batch subform which contains one action called Batch Scan and this subform must be inserted in every form where you need Batch Scan from Notes functionality. This action can not be used "out of the box" because it has to be set by customizing the code in it.
Lets look the code and some comments:
Sub Click(Source As Button)
Dim IMiSWorkSpace As New NotesUIWorkspace
Dim IMiSCurrUIDoc As NotesUIDocument
Dim IMiSCurrDoc As NotesDocument
Dim IMiSExtFlags As Long
Dim IMiSBatchProfile As String
Dim IMiSXMLFile As String
Dim IMiSDESCField As String
Dim IMiSFilesArray() As TIMiSObject
Dim IMiSResultINT As Integer
Dim IMiSResultLNG As Long
Call IMiSProcessMessages
Set IMiSCurrUIDoc = IMiSWorkSpace.CurrentDocument
Set IMiSCurrDoc = IMiSCurrUIDoc.Document
'SELECT IMIS/BATCHSCAN PROFILE
IMiSBatchProfile = ""
IMiSXMLFile = String$(260, Asc("."))
'Initialize IMiS/BatchScan
'Function IMiSBatchInit () As Long
'Return Value:
' 0 - everything is OK. Init process has finished with no errors.
' -1 - Init process has finished with errors. Most of the errors are reported to user.
IMiSResultLNG = IMiSBatchInit ()
If IMiSResultLNG <> 0 Then Exit Sub
'Clear selected profile in IMiSBatchScan (it means delete all files from profile)
'Declaration:
' Function IMiSBatchClear (Byval Profile As String, Byval ExtFlags As Long) As Long
' - Profile is name of profile user wants to clear
' - IMiSExtFlags:
' Const IMiS_BATCHCLEAR_DIALOG = 0 - ask for delete confirmation
' Const IMiS_BATCHCLEAR_NODIALOG = 1 - do not ask for delete confirmation
'Return Value:
' 0 - everything is OK. Clesr process has finished with no errors and selected profile is empty
' <> 0 - clear process has finished with errors. List of error codes:
' Const IMiS_BATCHAPI_UNKNOWN = -1 - unknown error
' Const IMiS_BATCHAPI_NOPROFILE = -2 - selected profile did not exist
IMiSExtFlags = IMiS_BATCHCLEAR_NODIALOG
IMiSResultLNG = IMiSBatchClear(IMiSBatchProfile, IMiSExtFlags)
If IMiSResultLNG <> 0 Then
Call IMiSBatchClose ()
Msgbox "Selected profile does not exist!",0 + 64 + 0 + 0 , "IMiS"
Exit Sub
End If
'Start IMiS/BatchScan application
'Declaration:
' Function IMiSBatchStart (Byval Profile As String, Batchfile As String, Byval ExtFlags As Long) As Long
' - Profile is name of profile user wants to start application with
' - Batchfile parameter will return path to IMiS/Batchscan XML file with created records
' - IMiSExtFlags:
' Const IMiS_DOBATCH_MANUAL = 0 - do not start scan process immediatelly; wait for user click
' Const IMiS_DOBATCH_AUTO = 1 - start scan process immediatelly
'Return Value:
' 0 - everything is OK. Batchscan process has finished with no errors.
' <> 0 - Batchscan process has finished with errors. List of error codes:
' Const IMiS_BATCHAPI_USERCANCEL = 1 - user did not save the profile
' Const IMiS_BATCHAPI_UNKNOWN = -1 - unknown error
' Const IMiS_BATCHAPI_NOPROFILE = -2 - selected profile did not exist and user has not created new profile
IMiSExtFlags = IMiS_DOBATCH_AUTO
IMiSResultLNG = IMiSBatchStart(IMiSBatchProfile, IMiSXMLFile, IMiSExtFlags)
If IMiSResultLNG <> 0 Then
Call IMiSBatchClose ()
Exit Sub
End If
'close IMiS/BatchScan
'Function IMiSBatchClose () As Long
'Return Value:
' 0 - everything is OK. Close process has finished with no errors.
' -1 - Close process has finished with errors. Most of the errors are reported to user.
IMiSResultLNG = IMiSBatchClose ()
If IMiSResultLNG <> 0 Then Exit Sub
Call IMiSProcessMessages
IMiSXMLFile = Left$(IMiSXMLFile,Instr(IMiSXMLFile,Chr(0))-1)
'SELECT IMIS/BATCHSCAN FIELD TO USE FOR DESCRIPTION OF OBJECTS
' - for barcodes use 'B#' + consecutive barcode number
' - for content fields use field name
IMiSDESCField = "B#1"
'Parse XML and put results in IMiSFilesArray array
IMiSResultINT = IMiSBatchXMLParser(IMiSXMLFile, IMiSDESCField, IMiSFilesArray)
If IMiSResultINT <> 0 Then Exit Sub
Call IMiSProcessMessages
'Iterate through array and send files to storage server; filenames in array are changed to ARC IDs
'Function IMiSArraySendToStorage(IMiSFilesArray() As TIMiSObject, ShowStorageSelectionDialog As Variant, Byval IMiSServerPrefix As String, 'Byval IMiSServerProfile As String) As Integer
IMiSResultINT = IMiSArraySendToStorage(IMiSFilesArray, False, "", "")
If IMiSResultINT <> 0 Then Exit Sub
'Iterate through array and add objects to Notes document
'Function IMiSAddObjectsToDoc(IMiSFilesArray() As TIMiSObject, SelectedUIDoc As NotesUIDocument) As Integer
IMiSResultINT = IMiSAddObjectsToDoc(IMiSFilesArray, IMiSCurrUIDoc)
Print " "
Call IMiSCurrUIdoc.Refresh
End Sub
Developer has to customize some lines in this code. Here are tips how to do that:
BATCHSCAN part:
- line 20: you should set the name of IMiS/BatchScan profile - IMiSBatchProfile variable. You can set it as constant or you can for example present dialog to user for profile selection. This is of course up to you and your case.
- line 29: IMiSBatchInit function is called - you should leave it as it is, because it is simply IMiS/BatchScan initialization.
- line 45: IMiSBatchClear function is called. You can use it to clear all the content from BatchScan profile. So it will delete all tiffs in profile and create empty XML file. As you can see in the code comments, you have option to select whether confirmation dialog is presented to user or not (IMiSExtFlags parameter).
- line 67: IMiSBatchStart function is called. this function will actually start BatchScan process. You pass profile name and flags (whether user should start scanning manually or scanning is started automatically - check IMiSExtFlags in code comment) and it will return path to XML file (IMiSXMLFile) and possible error code. It starts BatchScan in modal mode, so LotusScript code will not continue until user closes IMiS/BatchScan.
- line 78: IMiSBatchClose function is called - you should leave it as it is, because it simply closes IMiS/BatchScan.
PARSING XML file:
- line 88: It is very important to set appropriate object description. You can set it with IMiSDESCField variable, which describes which content item from XML should be used for object description. You can simply use content item name as you set it in BatchScan profile or you can use any Barcode. As describe in code comment, for barcodes use "B#" + consecutive barcode number or simply item name for content item.
- line 91: IMiSBatchXMLParser function is called. It parses XML file and creates IMiSFilesArray array with file paths and its descriptions based on IMiSDESCField setting.
SENDING FILES TO IMIS/ARC:
- line 98: IMiSArraySendToStorage function is called. It sends files from IMiSFilesArray to IMiS/ARC and change paths to ARC IDs in IMiSFilesArray. With additional parameters you can show storage selection to user or force which IMiS/ARC and its profile will be used as storage. By default IMiS/ARC is selected based on IMiS Setup settings (see for more details)
ADDING OBJECTS TO NOTES DOC:
- line 103: IMiSAddObjectsToDoc function is called. It writes valid objects (objects that do not migrate successfully to storage server in IMiSArraySendToStorage are not valid) from IMiSFilesArray to selected NotesUIDocument.
So it is very customizable. Developer can use function parameters to change behaviour or can use only some parts from this code. For example developer can skip ADDING OBJECTS TO NOTES DOC part and use your own code to write objects to Notes document from IMiSFilesArray based on your application logic, etc.
| Back | Main view | Parent doc