Skip to main content
Kofax

Modify the Suggested Values collection at runtime in a Workflow Agent

Question / Problem: 

How would I access and modify the Suggested Values collection at runtime in a Workflow Agent?

Answer / Solution: 

This example prints out the values in each Suggested Values collection defined in each Document in a Batch:

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using Kofax.Capture.SDK.Workflow;
using Kofax.Capture.ACWFLib;
using Kofax.Capture.DBLiteOpt;
using Kofax.Capture.SDK.Data;

 

namespace WFASuggestedValues
{
   [
Guid("9b3e8fa0-b585-49c6-a966-53332eca1982")]
   [
ClassInterface(ClassInterfaceType.None)]
   [
ProgId("WFASuggestedValues.WFAgent")]
   public class WFAValues : IACWorkflowAgent
   {
      public void ProcessWorkflow(ref IACWorkflowData oWorkflowData)
      {

         if (oWorkflowData.CurrentModule.ID.ToLower() == "fp.exe")
      {

      // Get the root & Batch elements.
      IACDataElement oRoot = oWorkflowData.ExtractRuntimeACDataElement(0);
      IACDataElement oBatch = oRoot.FindChildElementByName("Batch");

      // Get the Documents collection.
      IACDataElement oDoc = oBatch.FindChildElementByName("Documents");
      IACDataElementCollection oDocCol = oDoc.FindChildElementsByName("Document");

      // Get the SetupACDataElement root.
      IACDataElement oSetupRoot = oWorkflowData.ExtractSetupACDataElement(0);

      // Obtain the Batch Class definition of the current Batch.
      IACDataElement oCurrBatchClass = GetCurrentBatchClass(oSetupRoot, oBatch);

      using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@"c:\ValuesCollection.txt", true))
      {

         foreach (ACDataElement doc in oDocCol)
         {

            IACDataElement oDocClass = GetDocumentClass(doc, oCurrBatchClass, oSetupRoot);
            sw.WriteLine(
"***************************************************");
            sw.WriteLine(
"Document Class: " + oDocClass["Name"].ToString());
            // Iterate through the Index Fields Definitions collection
            IACDataElement oIndexDefs = oDocClass.FindChildElementByName("IndexFieldDefinitions");
            IACDataElementCollection oIndexDefsCol = oIndexDefs.FindChildElementsByName("IndexFieldDefinition");
            // Print out the Suggested Values for each Index field Definition
            foreach (IACDataElement oIndexDef in oIndexDefsCol)
            {
               sw.WriteLine(
"--------------------------------------");
               sw.WriteLine(
"IndexField Def: " + oIndexDef["Name"].ToString());
               IACDataElementCollection oValues = GetValuesCollection(oIndexDef["FieldTypeName"].ToString(), oSetupRoot);
               sw.WriteLine(
"Suggested Values:");
               foreach (IACDataElement oValue in oValues)
               {
                  sw.WriteLine(oValue[
"Text"].ToString());
               }
            }
         }
      }
   }

 

 

Applies to:  

Product Version
CAPTURE 10.2
  11.0