title: How to run a custom action method at the Field level
body: <p>I have a project in datacap that reads images, pdfs and csv's, recognize tables and exports those tables in JSON format.</p>
  
  <p>For this I have a custom action I wrote using the Datacap Template for C#.</p>
  
  <p>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.</p>
  
  <p>This is the prototype</p>
  
  <p><code>public bool XLSToJPG(string filePath);</code></p>
  
  <p>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.</p>
  
  <p>Prototype of the second method</p>
  
  <p><code>public bool getFieldInfo();</code></p>
  
  <p>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</p>
  
  <p>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.</p>
  
  <p>It does not matter what level i try, it always prints 0 as the current level.</p>
  
  <p>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 ;´(.</p>
  
  <p>This is the method i want to run</p>
  
  <pre><code>    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;
      }
  </code></pre>
  
  <p>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."</p>
  
  <p>The action should be called just at the field level when i set it to do so in the properties of the Rule.</p>
  
  <p>At the moment i have it running at "Any Object"</p>
  
  <p><a href="https://i.stack.imgur.com/BTK14.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BTK14.png" alt="enter image description here"></a></p>