IReRouteScript interface definition

This script is called after KC Plug-In receives a document from Message Connector, but before field mapping, XML mapping / rendering, or VRS processing. It has full access to the document and can modify it. The script can also insert or change the root XML and metadata fields used by rules.

Additionally, this script can split a document into multiple XML documents and return them to the Message Connector. The individual documents can be subsequently re-imported to KC Plug-In.

public interface IReRouteScript
    {
        /// <summary>
        /// Called reroute script
        /// </summary>
        /// <param name="message">The complete message, can be modified.</param>
        /// <param name="extension">Reserved for future use</param>
        //   1 : continue (withoutRefetch)
        //   2 : continue with refetch
        //   3 : Reselect destination without refetch.
        //   4:  Reselect destination with refetch
        //   5:  split docs : for EDI
        //   6:  other
        eMessageScriptCode ReRoute(Message message, object extension);
    }

The script returns one of the following options which determine how to proceed with a document.

Return value

Description

Continue

The destination that is selected in script is used and cannot change. Rules are ignored. It assumes that the user called ReRoute function from script. No refetch is performed.

SplitDocs

This is used for EDI file when an EDI files contains multiple EDI messages. Usage can be verified in the EDIReRouteScriptFile.cs file from C:\Program Files (x86)\Kofax\KIC-ED\KCPlugIn\Bin\script\.

ContinueWithRefetch

The destination that is selected in script is used and cannot change. Rules are ignored. It assumes that the user called ReRoute function from script. Any changes to the message from the script are discarded, the complete message is again fetched from the storage and it is processed according to the new destination.

ReSelectDestinationWORefetch

The message goes through the rules. If no rules match, messages go to the default destination. No refetch is performed. The import configuration of the selected destination (for example, conversion options) is ignored. It is assumed that the script has done all necessary work and rules are just used to select the appropriate destination.

To import EDI documents as EML or MSG, configure this in the routing destination. The default EDI script is using ReSelectDestinationWORefetch as return value. As a result, if importing as EML or MSG is enabled for the final destination, this setting is ignored.

ReSelectDestinationWithRefetch

Any changes to the message from the script are discarded and the complete message is again fetched from the storage. The message goes through the rules. If no rules match, messages go to the default destination. A message refetch is performed according to the new destination by calling ViewMessage.

"'IReRouteScript" is the main interface, however, in order to change the destination and reroute the message to other destination, implement a new script derived from the class Kofax.KCS.ImportConnector.Config.ReRoutingScript.

Implement the function public abstract eMessageScriptCode ReRoute(Message message, object extension). In this function, you can check conditions such as message size, message extension, etc., to change the destination. ReRoute must return values as defined in the table above. Additionally, you can change the destination using the protected void ChangeDestination(Message message, string destinationName) function.

Sample usage of the ReRoutingScript class can be found in the file MsgReRouteScriptFile.cs located in C:\Program Files (x86)\Kofax\KIC-ED\KCPlugIn\Bin\script\.

Kofax Import Connector includes the script EDIReRouteScriptFile.cs, located in C:\Program Files (x86)\Kofax\KIC-ED\KCPlugIn\Bin\script\. This script is used for importing of EDI documents. You can modify this default script, however, your changes might be overwritten on software reinstall or update.