Community

How to Force Verification if MORE THAN x checkmarks selected in OMR Group?

How to Force Verification if MORE THAN x checkmarks selected in OMR Group?

I have searched far and wide, but I still can’t figure out how to FORCE the Recognition if the user selects MORE than a specified number of Checkboxes in an OMR Group. 

In other words, for a particular OMR Checkmark Group, the group should be flagged for verification if the user selects MORE than THREE (3). 

I have a feeling this may have to be a Script.  But after searching Google, I still can’t find a decent example of how to do this. 

Thank you in advance!!!

 

0

Comments

7 comments

  • Avatar
    Ekaterina

    Hello,

    Please use the “Result” parameter and ICheckMarkGroupValue collection to create the Custom recognition script. More details you may see here: Using scripts in ABBYY FlexiCapture > Scripts for customizing processing stages > Types of scripts > Custom recognition script

    0
  • Avatar
    jacob

    Hi Ekaterina,

    Sorry it took me so long to reply.  It's been pretty crazy for us.  I created a C# Script as follows to handle this scenario.  In the future, it would be more helpful if you could include a quick code sample to show how exactly something like "ICheckMarkGroupValue" would be implemented.  I understand that for you, this is second hand and very easy.  But, for most of us who have not really worked within your Scripting engine, it is extremely confusing.  Here is the script;


    //C#.NET EVEN BETTER Script to Check OMR Checkbox Groups

    //Can use SPACE or Asterisk (*) to CLEAR Multiple Selections

    //________________________________________________________

     

    int numboxes = 0;

    int numtotalcheckboxes = 7;

    int numcheckboxesallowed = 3;

    string groupname = "TRUSTEES";

    string output = "";

     

    for (int i = 1; i <= numtotalcheckboxes; i++)

    {

        if (Context.Field(i.ToString()).Text != "")

        {

            numboxes++;

            output += ";" + Context.Field(i.ToString()).Text;

        }

    }

    if (Context.Field(groupname).Text == " " || Context.Field(groupname).Text.IndexOf("*") >= 0)

    {

        Context.CheckSucceeded = true;

        Context.Field(groupname).Text = "* INVALIDATED - More Than " + numcheckboxesallowed.ToString() + " * ";

    }

    else if (numboxes > numcheckboxesallowed)

    {

        Context.CheckSucceeded = false;

        Context.ErrorMessage = "More than three boxes checked for " + Context.Field(groupname).Name;

        Context.Field(groupname).Value = "";

    }

    else

    {

        if (!string.IsNullOrEmpty(output))

        {

            Context.Field(groupname).Text = output.Substring(1);

        }

        else

        {

            Context.Field(groupname).Value = "";

        }

    }

    0
  • Avatar
    Ekaterina

    Thank you for this sample.

    1
  • Avatar
    jacob

    Here is an improved version that displays more informative error messages;


    //C#.NET EVEN BETTER Script to Check OMR Checkbox Groups

    //Can use SPACE or Asterisk (*) to CLEAR Multiple Selections

    //________________________________________________________

     

    //Initialize variables - DO NOT CHANGE

    int numboxes = 0;

    string output = "";

     

    //Set Values for Current Field Group - CHANGE AS NEEDED

    //NOTE: groupname is the "Alias Name" configured in Available Fields

    int numtotalcheckboxes = 4;

    int numcheckboxesallowed = 4;

    string groupname = "TRUSTEES";

     

     

    for (int i = 1; i <= numtotalcheckboxes; i++)

    {

        if (Context.Field(i.ToString()).Text != "")

        {

            numboxes++;

            output += ";" + Context.Field(i.ToString()).Text;

        }

    }

    if (Context.Field(groupname).Text == " " || Context.Field(groupname).Text.IndexOf("*") >= 0)

    {

        Context.CheckSucceeded = true;

        Context.Field(groupname).Text = "* INVALIDATED - More Than " + numcheckboxesallowed.ToString() + " * ";

    }

    else if (numboxes > numcheckboxesallowed)

    {

        Context.CheckSucceeded = false;

        Context.ErrorMessage = "More than " + numcheckboxesallowed  + " boxes checked for " + Context.Field(groupname).Name;

        Context.Field(groupname).Value = "";

    }

    else

    {

        if (!string.IsNullOrEmpty(output))

        {

            Context.Field(groupname).Text = output.Substring(1);

        }

        else

        {

            Context.Field(groupname).Value = "";

        }

    }

    0
  • Avatar
    Safhan

     

    Hello

     

    This is almost what I need for my project, hope you can help me the rest of the way. I need to force verification, if there is MORE THAN ONE checkmark selected. I do not need any error messages or the feature with space/*.

     

    Where do I add the script? Is it for every field: Field Properties -> Recognition -> Filling type = Script recognition? If so, how do I keep the feature "allow corrections"?

     

    What is "groupname"? Is it "Name of field group" here: Field Properties -> Verification?

     

    0
  • Avatar
    jacob

    Hello safhan,

     

    If you look carefully at the top of the Script, I added a NOTE as follows:

     

        //NOTE: groupname is the "Alias Name" configured in Available Fields

     

    You can modify the Script to your needs.  But, you should have a relatively decent understanding of the C# programming language.

    If you need more help, you can use the following link to ABBYY Flexicapture 12 Help:

    https://help.abbyy.com/en-us/flexicapture/12/developer/script_recognition

    Unfortunately, this is all the help I can provide.  But maybe Ekaterina or another ABBYY user can provide additional help.

     

    Good Luck,

    Jacob

    0
  • Avatar
    Oliver Johnston

    I came across this post when looking for a similar solution to the problem whereby you need to enable multiple answers on a checkmark group, but also want to control how many answers are allowed; it seems a strange omission not having this feature built into in the program itself, as you usually want only a specified number of checkmarks people are allowed to mark

    I tried the above suggested solution, but it did not work for me, so I created a new routine for post recognition checking. This is VBScript

    This routine is put into the Checkmark Group Properties > Rules > Script

    You need to add each checkmark as an available field in the rule settings, A,B,C,D etc, along with the checkmark group itself, Q1_GRP etc

    Values are stored in the checkmarks as True/False, True equals checked

    The routine simply counts how many True values are present by adding everything to an array and excluding False from the count, and then compares that to a value set in ALimit, which is how many checkmarks are allowed to be made in a correct scenario.

    If it is less or more then if forces verification.

    You can edit the ALimit to however many you require, and there is no group name to worry about as that is piped through in the ME: by default.

    In my example two boxes are allowed, out of a total of 5, ABCDE

    Simply amend the ReDim (Total-1 because arrays start at 0) and amount of array items to correspond to your total checkboxes in the group, along with the field names, which come from the Alias name in the rule Available fields settings box.

    You can also remove the last elseif statement if you don't want to check if too few answers are made.

    I also used the apply rule condition, and created a text box called override rule check, with a default value of 0 displayed on the data form, which a verification operator can change to 1 to force through the submitted answers if there is a need.

    ********Copy Below***************

    Dim intItems, strItem, sizeOfArray, arrItems(), ALimit

    ALimit = 2

    ReDim arrItems(4)
    arrItems(0) = me.Field("A").Value
    arrItems(1) = me.Field("B").Value
    arrItems(2) = me.Field("C").Value
    arrItems(3) = me.Field("D").Value
    arrItems(4) = me.Field("E").Value

    n = 0

    For Each strItem in arrItems
    if not strItem = "False" Then
    n = n + 1
    end if
    Next

    if n > ALimit Then
    me.CheckSucceeded = False
    me.ErrorMessage = "Too many Answers Selected" & ": " & n

    Elseif n < ALimit Then
    me.CheckSucceeded = False
    me.ErrorMessage = "Too few Answers Selected" & ": " & n
    else
    end if

    0

Please sign in to leave a comment.