IDocumentScript2 interface definition
Following is the definition of the IDocumentScript2 interface.
public interface IDocumentScript2
{
/// <summary>
/// Called before the import content and import order is determined
/// Body and attachment content and import order can be manipulated in this function
/// </summary>
/// <param name="messageBody">A read-only instance of the message being imported</param>
/// <param name="messageBody">The list of the received message bodies.</param>
/// <param name="attachments">The list of the received attachments.</param>
/// <param name="extension">Reserved for future use.</param>
void ManageMessageFiles(ReadonlyMessage message,
List<Attachment> messageBody,
List<Attachment> attachments,
object extension);
/// <summary>
/// Called before a document is imported into KC
/// </summary>
/// <param name="indexFields">The list of index fields defined in the configured document class.
/// If document class not defined this will be empty.</param>
/// <param name="folderFields">The list of folder fields defined in the configured folder class.
/// If folder class not defined this will be empty.</param>
/// <param name="batchFields">The list of batch fields defined in the configured batch class.</param>
/// <param name="messageBody">The list of the received message bodies.</param>
/// <param name="attachments">The list of the received attachments.</param>
/// <param name="extension">Reserved for future use.</param>
void BeforeDocumentImport(IDictionary<string, string> indexFields,
IDictionary<string, string> folderFields,
IDictionary<string, string> batchFields,
List<Attachment> messageBody,
List<Attachment> attachments,
object extension);
/// <summary>
/// Called before a message is imported into KC
/// </summary>
/// <param name="indexFields">The list of index fields defined in the configured document class.
/// If document class not defined this will be empty.</param>
/// <param name="folderFields">The list of folder fields defined in the configured folder class.
/// If folder class not defined this will be empty.</param>
/// <param name="batchFields">The list of batch fields defined in the configured batch class.</param>
/// <param name="messageBody">The list of the received message bodies.</param>
/// <param name="attachments">The list of the received attachments.</param>
/// <param name="extension">Reserved for future use.</param>
void BeforeMessageImport(IDictionary<string, string> indexFields,
IDictionary<string, string> folderFields,
IDictionary<string, string> batchFields,
List<Attachment> messageBody,
List<Attachment> attachments,
object extension);
}
If defined, the ManageMessageFiles function implementation is run before the import content and import order is determined. Here you can manipulate the import content: add new content, discard content, and change existing content. You can discard binary content by setting a DoImport flag of the binary content to false to skip the import of that attachment or body.
If defined, the BeforeDocumentImport function implementation runs before each Kofax Capture document is created.
If defined, the BeforeMessageImport function implementation runs before each message is imported into Kofax Capture.
The input parameters for the BeforeDocumentImport and BeforeMessageImport methods are the list of all folder, document and batch field values, the list of all message bodies, and the list of all attachments. Here you can manipulate batch, folder, and document field values. The list of bodies and attachments are only for reading in these functions. You cannot change the import content. If you need to manipulate the import content, this should be done in ManageMessageFiles.
The indexFields parameter contains a key-value pair list containing all the index fields defined for the used document class. If a document class is not configured or if there are no index fields defined, this will be empty. The key property contains the index field name and the value property contains the index field value.
The folderFields parameter contains a key-value pair list containing all the folder fields defined for the used folder class. If a folder class is not configured or if there are no folder fields defined, this will be empty. The key property contains the folder field name and the value property contains the folder field value.
The batchFields parameter, similar to the indexFields and folderFields parameter contains a key-value pair list containing all the batch fields defined for the used batch class. If there are no batch fields defined, it is empty. The key property contains the batch field name and the value property contains the batch field value.
The messageBody parameter contains all the selected representations of the message body (original, PDF, TIF).
The attachments parameter contains all the selected representations of the attachments (original, PDF, TIF).
Attachment class properties
Property name |
Type |
Description |
---|---|---|
Extension |
String |
The extension of the received file. |
LongOrBinaryFileName |
String |
The file name of the received attachment/body. The connector first looks for the long file name, if it does not exist, then it takes the binary file name, which is the short file name. |
HierarchicalPosition |
String |
MC hierarchical position of the file. |
DoImport |
Bool |
By default, it is true. If this value is set to false in script, this attachment/body will not be imported into Kofax Capture. |
Content |
Byte[] |
The binary content of a body/attachment. If it is text, then it is encoded using the default Windows encoding on the computer where the connector runs. |
DocConversionError |
String |
If there was a document conversion error for this document, this property will contain the description of the error. |
IsOriginal |
Bool |
Indicates if a file is an original file or a converted file. |
IsImage |
Bool |
Indicates if it is an image or another file format. |
IsOriginalEml |
Bool |
Indicates if it is the EML representation of the original message. |
ContentID |
String |
MIME content ID. If not set by Message Connector, the value is null. |
ContentDisposition |
String |
MIME content disposition. If not set by Message Connector, the value is null. |
CreationDate |
DateTime |
Creation date of original file/attachment. If not set by Message Connector, the value is 01.01.0001 00:00:00. The date/time value is always displayed in the UTC format. This property is applicable to files/attachments imported via email and folder.
When an EML/MSG file is imported using folder import, the creation date value for the file/attachment is always
returned as 01.01.0001 00:00:00.
|
ModificationDate |
DateTime |
Modification date of original file/attachment. If not set by Message Connector, the value is 01.01.0001 00:00:00. The date/time value is always displayed in the UTC format. This property is applicable to files/attachments imported via email and folder.
When an EML/MSG file is imported using folder import, the modification date value for the file/attachment is
always returned as 01.01.0001 00:00:00.
|
ContentType |
String |
MIME type of the original attachment. If not set by Message Connector, the KC Plug-In will set it depending on the file extension of the attachment. |
ActualType |
String |
Type of the attachment set by Message Connector. Possible values: TEXT , BINARY_IMAGE, BINARY_nonIMAGE, ROOT_XML. |
IsXmlRendering |
Bool |
Indicates that the attachment is the result of a converted XML document. |
OriginalFileName |
String |
Contains the original file name of the attachment with the original extension, such as, when a document is converted, it has a different name/extension. |
QueueId |
Integer |
Unique identifier of the queue in which a specific message will be processed. |
FilePath |
String |
This is the temporary folder path where the converted files are saved. |
GuidFilePath |
String |
File path name with GUID to avoid name collisions in case of attachments with same names. |
FileName |
String |
Contains the fine name of the attachment. File name is either the name of the converted document or the original file name. |
OriginalFileWithPath |
String |
Contains the complete path of the input file. |
IsConvertedFromImage |
Bool |
Indicates if the original file format of the converted file was an image or other. |
CaptureFileName |
String |
The file name assigned by Kofax Capture at the time of file import. |
IsBody |
Bool |
Set to true only if the attachment is qualified as email body. |
IsOriginalMsg |
Bool |
Set to true only if the original document is a msg file. |
VRSErrorContext |
String |
Contains the errors returned from the VRS commands. |
rootXml |
XmlDocument |
Contains the XML content which is being imported. |
IsXmlRendering |
Bool |
Set to true if XML rendering is enabled. |
ConvertByteArrayToFile |
Byte[] |
Creates file from byteArray and assign the file location to FilePath. Only for internal use. Do not change.
|
ConvertFileToByteArray |
Byte[] |
Creates byteArray from file. Only for internal use. Do not change.
|
InstanceId |
Integer |
Contains the Kofax Import Connector process instance. Only for internal use. Do not change.
|
OriginalContentType |
eContentType |
Contains the content type of the original attachment. |
Id |
String |
GUID of the current attachment. |
ExtractFrom |
String |
Contains the name of the zip file if the file has been extracted from a zip file. |
TiffPageCount |
Integer |
Contains the total number of pages calculated from the imported TIFF file. |
Rejecting messages from script
You can perform checks and reject messages with scripts that implement the IDocumentScript2 interface. To reject a message, throw an exception of the type ScriptException with the desired description as an argument. The description is then displayed in the Message Connector Monitor.
Ignoring messages from script
You can perform checks and ignore messages with scripts that implement the IDocumentScript2 interface. To ignore a message, throw an exception of the ScriptIgnoreMessageException type with the desired description as an argument. In order to work correctly, ScriptIgnoreMessageException needs to be thrown from the function ManageMessageFiles. Optionally, when throwing the exception, you can also select not to send a notification and not to archive the message by passing false as value for doNotifyArchive in the exception constructor. Similar to reject, ignore causes the message not to be imported into Kofax Capture. The difference is however, that ignore will send a positive confirmation back to Message Connector and provides the option to turn off archiving and notifications for such messages.