0

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

YouHaveNoSkill
  • 53
  • 1
  • 11

1 Answers1

0

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

Krunal Barot
  • 914
  • 6
  • 17
  • At the moment im using an Action Library called FindTableValueRegex or so, i don't remember the name at the moment but what it does, it recognizes a table in a document. First you have to create a Layout recognition, i included the action ocr_a->Recognize() and it creates that layout for me, then i run FindTableValueRegex and i can pick values from the table, It will create the fields dynamically, so there is no Fields defined in the DCO. They are created at Runtime. – YouHaveNoSkill Feb 06 '19 at 19:00
  • I have run the example method when you created a new Datacap Custom Action from the template in c#, and the method runs in every level. It is strange why it does not work on mine, since i modified the same template, and the only thing i have edited is the method name and its code, deleted the template method, and created the xml in the TheRRX file so it can be loaded from datacap studio.At least i know it is possible to run such levels in c#, I just seem to miss something that is making mine not work. – YouHaveNoSkill Feb 06 '19 at 19:00
  • ok .. try to keep all as it is and do not delete anything.. there are few methods/functions in it which are needed for the running of dll . just copy paste existing sample methods and rename them .. – Krunal Barot Feb 07 '19 at 09:34
  • If this answer is useful, please consider to tick it as answer. thanks – Krunal Barot Feb 07 '19 at 12:08