Community

Verify the content of a QR Code in FlexiLayout Studio to match the layout Answered

Hi,

In FlexiLayout Studio 12 I created a new FlexiLayout which recognizes a QR-Code situated in the top-right corner of the page and matches the document if it's recognized.

It works, but I wish to match the layout only if the QR-Code contains some data or has a valid structure.

I think I should use some Advanced post-search relation script to completely penalize the field if the QR-Code is not valid, but I am not sure as I've never used this before.

Could you help me please? Do you have any other ideas?

Thank you very much, bye!

Was this article helpful?

0 out of 0 found this helpful

Comments

5 comments

  • Avatar
    Alexey Efremov

    Hello,

    Please see the article "FlexiLayout Language > Hypotheses and their properties > Hypotheses for all types of elements" of the FlexiLayout Help file. It contains the exact example of what you are looking for.

    If you have any further questions, please let me know.

     

    0
  • Avatar
    Mattia Martinello

    Please see the article "FlexiLayout Language > Hypotheses and their properties > Hypotheses for all types of elements" of the FlexiLayout Help file. It contains the exact example of what you are looking for.

    Hi Alexey, thank you very much for your answer.

    I've already checked that help file, are you referring to the section "Example: accessing the properties of a hypothesis", aren't you?

    That example simply checks if the value of a field is exactly equal like a given value, but I have to make something more complex.

    The QR Code I have to match in my layout can contain only a text string with fields separated by pipe (|) and each field has to match the keyalue format.

    If the QR Code matches this format, the layout is matched, else not.

    For this reason I think I should write some JScript code, which I understand I cannot insert into the search relation in FlexiLayout studio, right?

    Would it be better to create a new script step into the workflow which takes only this FlexiLayout, checks the QR Code, and delete the match and route the document to the Recognition again if the QR Code is not correct? But doing so it would be matched again on the same FlexiLayout. So how I could avoid this endless loop?

    Thank you very much!

    0
  • Avatar
    Alexey Efremov

    Hello,

    For this purpose you can use the method Find of the String class:

    Int Find(String subStr, Int startPos = 0)

    Description:

    Returns the beginning of the substring subStr of the string. Starts the search from the startPos position. Can be used without the startPos argument, in which case it assumes the default value of 0. Returns -1 if the string does not include a startPos substring.

    So the code will look like:

    if value.Find("something") >= 0 then {

    //do stuff

    }

    Please check out the article "FlexiLayout Language > Predefined types" to learn more extension methods

     

    1
  • Avatar
    Alexey Efremov

    Regarding the question about the endless loop:

    First way is to use event "Before matching" to restrict the Document Definition used.

    After the first recognition you create a registration parameter, that indicates that the first recognition has passed.

    Another way is creating a second recognition stage and restricting the Document Definition used for both stages in the stage properties of the workflow.

    But I think you will not need this information now

     

    0
  • Avatar
    Mattia Martinello

    if value.Find("something") >= 0 then {

    //do stuff

    }

    Thanks Alexey!

    I made this way and it works!

    0

Please sign in to leave a comment.