Search code examples
c#kofax

Kofax Total Agility: moving a document job programmatically to a specific process step


I am working on Kofax Total Agility with a basic BPMN (Business Process Model and Notation). This process contains differents steps:

  • classification
  • document review
  • data extraction
  • document validation & verification
  • a c# external call
  • finally an export

enter image description here

My objective is to make future processes easier to manage by developping modules. In the Workspace, I can import documents and manage all the process and export document in the end and it work fine.

I tried to find in the API documentation the Services and Methods that can be called and used externally. In this process, When I reach the externalCall step of the process I would like to return to the classification step or the document review depending on a value retrieved in the verification step.

Passing a variable from verification to externalCall is easy. My issue is to know how to "move" an activity to a previous step programmatically for one or several document imported in a process. In this case i would like to reassign a document to validation step or extraction step after verification and externalCall in the workflow.

I found method such as ReassignActivity which is in ActivityService. My question would be to know how to get the required variables to make it possible. For example, how do I retrieve the ResourceIdentity object (original and new resource), the JobActivityIdentity object, etc. Do I need to create a new Job ? if yes, do i have to get the jobId of the previous job ?


Solution

  • I finally found out a solution. I created a dll that allows me to create a new Job and delete previous job at a certain point of a workflow.

    For this I used the JobIdentity CreateJobAndStartAt method. At this stage, it's rather easy to get the sessionId required because it's a system variable.

    Basically, I implemented a method this way :

    public class AppJobService
    {
        public JobIdentity CreateJobAndStartAt(string sessionId, string jobIdentityId)
        {
            JobIdentity returnValue = null;
            var js = new sdk.JobService();
    
            var pai = new ProcessActivityIdentity();
            pai.ActivityName = Constants.activityName;
    
            var pi = new ProcessIdentity();
            pi.Name = Constants.processIdentityName;
    
            try
            {
                returnValue = js.CreateJobAndStartAt(sessionId, pi, new JobInitialization(), pai);
    
                // call terminate job
                JobIdentity currentJi = new JobIdentity();
                currentJi.Id = jobIdentityId;
                TerminateJob(sessionId, currentJi);
            }
            catch (Exception ex)
            {
                throw;
            }
            return returnValue;
        }
    
        void TerminateJob(string sessionId, JobIdentity jobIdentity)
        {
            var js = new sdk.JobService();
            try
            {
                js.TerminateJob(sessionId, jobIdentity);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
    }
    

    This code works fine ! My questions are the following:

    1. is there a way to retrieve dynamically the process name and pass it as variable ? At this stage I hard coded it : Constants.activityName
    2. is there also a way to pass a variable to this new Job ? for example a boolean that returns true if the dll was called or not
    3. is there a way to retrieve the previous activity name ? it could be useful if i plan to reuse the method at different step of the process and create a new job one step before