Community

How to make a database check rule execute when a field value changes?

I need to execute a Database check rule for a Field (A) which populates other fields (B,C) only when the field value is changed. This means that after recongnition of the field, and if user changes its value the rule must be executed.
I was not able to find a simple way to do this.
I was able to mimic this by adding two Dummy fields (D1, D2) and implementing the following:
- Default value for D2 is zero.
- The database check rule for field A was configured to be executed when D2 is zero.
- When the database rule is executed it fills D1 with the table field which is used to match A.
- A script rule was created in order to check ifField A = Field D1 then D2 is set to zero , forcing the database rule to run again-

There must be an easier way...
Anyone can help with this issue?

Thanks for your help.


Was this article helpful?

0 out of 0 found this helpful

Comments

5 comments

  • Avatar
    Permanently deleted user
    Hello,

    That is an interesting approach using only standard functionality to execute database checks.

    As an alternative consider using scripts, there are two possibles solutions:

    1.User script (Custom action), custom action script is a script that is executed only when user clicks a button that will appear after creating such a script in field's properties.
    Check help file for more info: FlexiCapture help administrator->Program settings > Document Definitions > Field properties > Text entry fields > Custom action

    2.Rule script + one Flag field. This approach is similar to your current solution, Field (A) will contain a script similar to the following

    C#:

    If (Context.Field("D2")="")
    {
    Context.Field("D1").Text=Context.Field("A").Text; //this line will be executed after recognition to store originial value
    }
    else
    {
    if (Context.Field("A")!=Context.Field(D1)) //this line checks if field A was changed
    {
    //database check script
    }
    }

    Check help file for more info: FlexiCapture help administrator->Appendix > Using scripts in ABBYY FlexiCapture




    0
  • Avatar
    Alberto Torino
    Thanks Timur for your feedback.
    Unfortunatelly custom actions are not a very realiable way because you need to rely on the user. Even though we have found a workaround for the problem , it can't be applied always. If you have a table and you need to query a database based on column it would became very complex, since you will be needing extra fields for each row.
    I'm sure someone must have had this problem before and there is a better, cleaner, and simpler solution.
    Best Regards,
    0
  • Avatar
    Permanently deleted user
    Hello,

    Rules are always executed during recognition and after any field that they use is modified.

    If creating additional fields is not an option, then as a workaround consider using the following approach:

    1.Create data base check using a script rule
    2.Create an additional batch processing stage, for example "DataBaseCheck"
    3.Wrap created rule script inside a stage name check:

    if (Context.Document.Batch.StageInfo.StageName=="Data BaseCheck")
    {
    execute Data base check script
    }

    4.Route documents to this stage after verification

    5.Route documents back from DataBaseCheck stage to verification if any errors occur.

    This way after operators have made needed corrections and closed the task, documents will go to an additional stage where data base check script is allowed to be executed.
    and reuturn to verification if database check fails.

    Please reply if you have any questions or need more details.
    0
  • Avatar
    Alberto Torino
    Thanks again for your feed back Timur.
    That approach does not allow me to perform what i want, may be I should clarify what i need:

    - After document recognition , Database check should be performed based on recognition, so probably all fields are going to have some data because either they were recognized or they were filled in by database check rule. So using db check option "Fill in with db value only if field is empty" is of no good.

    - Fields that are filled up by database rule CAN be modified by operators. So if the database rule checks field A against a table and fills in Field B and Field C, field B, and C can be ovewritten by operator.
    As you correctly state, DB Check rules are performed always, so after the operators overwrite field B with a new value, as soon as they press entrer, the DB check rule is executed, replacing operator's input with db content.

    - In case operator changes field A, we want the db rule to execute again.


    May be you can think of values pulled out of the db as suggested values for the fields.

    May be this could be implemented in Flexicapture as a new option for executing db check rules ,only when value changes. I think that is very common situation.

    I was able to implment a "near to desire" behaviour when db check rule applies to a field of a Table. But its very clumsy.

    Thanks again for taking the time to analyze my problem.

    Kind Regards,

    Alberto

    0
  • Avatar
    Permanently deleted user
    Hello,

    Thank you for additional details.

    I think what you need can be accomplished with using the follwoing approach:

    1.Create additional script stage after recognition to save original values of field A for further use

    1.Create a script rule with db query and several conditions to have it run when needed:
    - you can check if fields A B or C are empty and decide to continue with db check or exit the rule
    - Since original value of field A is saved in document properties, it will be possible to detect if field A was modified, and not execute db query when operators change only fields B or C. This way you won't have to create additional fields or store db check results in a list of suggested values.

    Feel free to ask questions if you need more details on using this approach.

    Best regards,
    Tim









    0

Please sign in to leave a comment.