How to run a custom action method at the Field level

1.3k views Asked by At

I have a project in datacap that reads images, pdfs and csv's, recognize tables and exports those tables in JSON format.

For this I have a custom action I wrote using the Datacap Template for C#.

The first method in this custom action is used to load CSV's and it worked fine because it starts at the Batch Level, thus i did not realize my problem until later.

This is the prototype

public bool XLSToJPG(string filePath);

Everything was fine until I wrote a second method to write some logs for each field recognized in my datacap like the confidence of the characters. Realized i can not call other levels rather than Batch like Document, Page, Field or Character Level.

Prototype of the second method

public bool getFieldInfo();

Im printing logs of the current level when the method is called to test. If it prints 0 is then is Batch level, 1, 2, 3, 4 are Document, Page, Field and Character respectively

I wrote logs trying to see if the method is called for any level. In the rulset i set "Run at the start of..." and picked "Any Object" instead of a Field. That means it should be called for all levels. Didn't work.

It does not matter what level i try, it always prints 0 as the current level.

First the method(action) was called inside function right after getting the fields on a previous function, then i tried in its own Rule, then In its own Ruleset, 0 luck ;ยด(.

This is the method i want to run

    public bool getFieldInfo() {
        bool response = false;

        WriteLog("Getting field confidence...");
        WriteLog("Current Level: " + DCO.ObjectType());

        string confidence = DCO.AltConfidenceString[0];

        WriteLog("The current field confidence is: " + confidence);

        response = true;

        //switch (DCO.ObjectType()) {
        //    case Level.Field:
        //        break;
        //    default:    
        //        WriteLog("getFieldInfo should run on the field level.");
        //        break;
        //}


        return response;
    }

You can see how i ran out of options and removed the switch to print the log on every call, it always printed "getFieldInfo should run on the field level."

The action should be called just at the field level when i set it to do so in the properties of the Rule.

At the moment i have it running at "Any Object"

enter image description here

1

There are 1 answers

4
Krunal Barot On

ok.. so i assume the dll is created with various functions in it and you want second function at field level. -if you are using datacap studio(off-course it will be) there will be the first box on the left hand side with doc hierarchy.. -in that you can set a function from the ruleset(middle) which is added from your dll which is shown on the right most side.. -you can add that function to a field inside the doc hierarchy which will run only if that field is executed in the ruleset to check anything.

i will try to get some screen-holds when home..

hope this helps