Generally speaking, Kofax organizes any kind of mapped data as so-called Links
. However, it does not take care of mapping anything on its own, that is our job (for some reason). You will find two different objects at your disposal:
- Your setup script will contain a reference to a
ReleaseSetupData
object, usually named SetupData
.
- Your release script has another reference to a
ReleaseData
object, namely DocumentData
.
Now, all links established during setup time will become available during release time. Said links can contain different kinds of data, for example index fields, batch fields, Kofax values, or custom properties. Now, let's say you have the index field "FirstName" on your document class, and you do want to access its value during release time - here's what you need to do.
Setup Script
setupData.Links.Add(
setupData.IndexFields["FirstName"].Name,
KfxLinkSourceType.KFX_REL_INDEXFIELD,
setupData.IndexFields["FirstName"].Name);
setupData.Apply();
Please keep in mind that those links are similar to dictionary entries, so you can't link the same item twice. I usually like removing all links when my setup script loads, and add them again when it unloads again (and note that you can safely loop over the setupData.Indefields collection to add all fields instead of just a single one).
Release (Run) Time
During release, all links are then made available in the DocumentData.Values
collection. To access your index field and its value, here's what you need to do. The following assumes you already set up a Dictionary<string, string>
named IndexFields
, and it further shows you how to access all other kinds of links (batch fields, custom properties, et cetera):
foreach (Value v in DocumentData.Values)
{
switch (v.SourceType)
{
case KfxLinkSourceType.KFX_REL_BATCHFIELD:
BatchFields.Add(v.SourceName, v.Value);
break;
case KfxLinkSourceType.KFX_REL_DOCUMENTID:
break;
case KfxLinkSourceType.KFX_REL_INDEXFIELD:
// index fields may also contain table fields
if (v.TableName == "")
{
// this is a regular index field
IndexFields.Add(v.SourceName, v.Value);
}
else
{
// this is a table field!
}
break;
case KfxLinkSourceType.KFX_REL_TEXTCONSTANT:
TextConstants.Add(v.SourceName, v.Value);
break;
case KfxLinkSourceType.KFX_REL_UNDEFINED_LINK:
break;
case KfxLinkSourceType.KFX_REL_VARIABLE:
break;
}
}
If you wanted to map Kofax Index Fields to some external ID, you could safely do so using Custom Properties. Example: you can assign the id 42 to FirstName during setup (just create a property grid with a custom class), add the Custom Property during setup time, and then access its value during release. That way you could maintain ids via the setup form without the need to ever rebuild your solution.