1

I am trying to create a job using SDK. Simple job with send email activity work like a charm!

But when I try to create a job with variables input folder to import few images it doesn't work at all. Am I missing very trivial settings ?

My process has classification activity & extraction activities Variables : DefaultImportFolder

FYI : My process works fine if I set import settings -> import sources. That tells me there is no issue with my process process Smile. But when I try to run through console app with dynamic variables, it doesn't work.

Following is my sample code. Any help?

ProcessIdentity processIdentity = new ProcessIdentity
            {
                Name = "SDK TestProcess"
            };

            var jobService = new TotalAgility.Sdk.JobService();
            JobInitialization jobInitialization = new JobInitialization();

            InputVariableCollection variablesCollections = new InputVariableCollection();
            InputVariable inputVariable = new InputVariable
            {
                Id = "DefaultImportFolder",
                Value = @"\\FolderPath",
            };
            variablesCollections.Add(inputVariable);

            inputVariable = new InputVariable
            {
                Id = "ExportSuccess",
                Value = "true"
            };
            variablesCollections.Add(inputVariable);

            var createJobAndProgress = jobService.CreateJob(sessionId, processIdentity, jobInitialization);

            Console.WriteLine($"Job ID {createJobAndProgress.Id}");

As Suggested by Steve, tried with WithDocuments method Still no luck .....

JobWithDocumentsInitialization jobWithDocsInitialization = new JobWithDocumentsInitialization();

                Agility.Sdk.Model.Capture.RuntimeDocumentCollection documentsCollection = new Agility.Sdk.Model.Capture.RuntimeDocumentCollection();

                Agility.Sdk.Model.Capture.RuntimeDocument runtimeDoc = new Agility.Sdk.Model.Capture.RuntimeDocument
                {
                    FilePath = @"FolderPath\abc.tif",

                };

                documentsCollection.Add(runtimeDoc);

                jobWithDocsInitialization.Documents = documentsCollection;


                var jobIdentity = jobService.CreateJobWithDocuments(sessionId, processIdentity, jobWithDocsInitialization);
                Console.WriteLine($"Job ID {jobIdentity.Id}");
ktaSharp
  • 27
  • 7

1 Answers1

1

A folder variable represents a reference to a folder that already exists in the KTA database, so you can't just set a file path to the variable. When you create a job via an import source, it is creating the folder and documents as part of creating the job.

To do the same in your code, you would use one of the "WithDocuments" APIs such as CreateJobWithDocuments which has parammeters specific to importing documents into the process, including by file path.

As discussed in this other answer (Kofax TotalAgility Send a PDF Document to Jobs Queue (KTA)), you may want to look at the sample code that is included with the product (that most people don't realize is available), and also look at other API functions for more context on the parameters needed for the "WithDocuments" APIs mentioned above.

Stephen Klancher
  • 1,374
  • 15
  • 24
  • Stephen, Thank you for the information. I have changed my code to use CreateJobWithDocuments with jobInitialization. Still no luck! Any suggestions ? – ktaSharp Dec 07 '20 at 00:57
  • You need to make sure you are create a collection of RuntimeDocument and set the FilePath property. Make sure the user running the code can access the file path. If you're still having problems you will want to post your full updated code be be clear what is actually happening (exception in code? job suspends? unexpected results in job?) RuntimeDocument: https://docshield.kofax.com/KTA/en_US/7.8.0-dpm5ap0jk8/help/API/latest/class_agility_1_1_sdk_1_1_model_1_1_capture_1_1_runtime_document.html – Stephen Klancher Dec 07 '20 at 02:12
  • 1
    I found the issue, the inputVariable is case-sensitive. Once I matched the variable case, I am able to import documents. Thank you! – ktaSharp Dec 07 '20 at 22:39
  • Is it possible to create or upload a document to an existing folder id ? – ktaSharp Dec 08 '20 at 23:13
  • Not as part of creating a job, no. If you wanted to do such a thing later in your process, use the MoveDocument API. But also create new posts for new questions. https://docshield.kofax.com/KTA/en_US/7.8.0-dpm5ap0jk8/help/API/latest/class_agility_1_1_sdk_1_1_services_1_1_capture_document_service.html#a22f1b02137f59282bb8bc2728dc3c054 – Stephen Klancher Dec 09 '20 at 17:47
  • Sure will do. Thank you again! – ktaSharp Dec 09 '20 at 18:49