Search code examples
c#releasekofax

Kofax - How to make Release Script configuration dependent on an active job


I am implementing a Kofax release script class through IReleaseScript2 interface (that also inherits IReleaseScript interface).

The problem is, that I need to have my release script's configuration dependent on currently selected job.

Method Setup has a parameter of type IJob which is OK, but other methods don't.

Thanks for your advice!


Solution

  • Are you talking about Kofax Capture or KTA? In both cases you'll need a reference to Kofax.ReleaseLib.Interop. Basically, each Export Connector (or Release Script, as they were called in the past) consists of two parts:

    1. The Setup Part - this is where the configuration resides. When adding an Export Connector to a Document Class in Administration, you want to configure it and store the configuration.
    2. The Release Part - this is where the "real thing" happens, i.e. documents get exported to disk, database, et cetera.

    The Setup Part must implement IReleaseSetupScript, hence adding the following methods (this is a stub):

    public interface IReleaseSetupScript
    {
        ReleaseSetupData SetupData { set; }
        KfxReturnValue OpenScript();
        KfxReturnValue CloseScript();
        KfxReturnValue RunUI();
        KfxReturnValue ActionEvent(KfxActionValue Action, string strData1, string strData2);
    }
    

    The most essential part is the RunUI method - here's where you want to show a dialog, let the users do their configurations, and then store it. Let's say you want to export documents to disk - you want to provide your users with a textbox where they can enter a path. Said path is stored as a link in the SetupData object.

    The Release Part itself must implement IReleaseScript (or, for that matter, IReleaseScript2), here's a stub of the methods:

    public interface IReleaseScript
    {
        ReleaseData DocumentData { set; }
        KfxReturnValue OpenScript();
        KfxReturnValue CloseScript();
        KfxReturnValue ReleaseDoc();
    }
    

    You'll see where this is going. OpenScript and CloseScript are called once per batch (i.e. the job, or the instance of a batch class). ReleaseDoc is called once for each document in said batch. Again, you can access the configuration via the ReleaseData object (custom properties or values as key-value pairs).

    If you're talking about KTA, then I'd recommend not writing an Export Connector, and instead going for a dll that accesses the current job's objects (e.g. documents, metadata) that you will add as a .net activity.