Using rules

This article describes how to use template field rules in Continia Document Capture, either set up with regular expressions or standard operators.

Why use rules in Document Capture

Using rules in Document Capture allows you to control which values are valid in a template field. During the field recognition process, these rules ensure that only values that match the rule specified for each field are recognized. Therefore, automations are only triggered if your values are fully correct. This is particularly useful if you have vendors who tend to change the layout or content of their documents, making it easier to spot false positives.

Additionally, rules set up on required fields guarantee that documents are only registered if these fields are correctly recognized or filled out.

Rules, regular expressions, and operators

Template fields with the data type set to Number only accept standard operators (such as >, <, and =), and template fields with the data type Text support regular expressions – also known as regex. Regular expressions are basically a sequence of digits, letters, and special characters that specify a match pattern. For example, the regular expression \d{4}-\d{2}-\d{2} corresponds to the following:

  • \d - any digit from 0 to 9.
  • {4} - exactly four of the preceding element, so \d{4} matches exactly four digits.
  • - - a hyphen.
  • \d{2} - exactly two digits.
  • - - another hyphen.
  • \d{2} - exactly two digits.

Therefore, the regular expression shown above can be used to match dates in the format yyyy-mm-dd.

For more examples of valid expressions, see Using rules in header fields and Using rules in line fields below.

Bemærk

Rules are case insensitive.

Using rules in header fields

When using rules on header fields, you can filter the recognized value – that is, the value is only recognized if its data complies with the rule.

To add a rule to a header field:

  1. Choose the Search icon, enter Document Categories, and then choose the related link.
  2. Select the PURCHASE code to open the document journal.
  3. In the list of documents, select the document whose template field you want to set up a rule for.
  4. In the Document Header section, select the three dots by the header field you want to set up a rule for.
  5. In the action bar, select Rules. Alternatively, you can edit the Rule field on the General FastTab.

Below are some examples of regular expressions that can be used in header fields.

ExpressionDescriptionExamplesResults
P[0-9]{8}The field value must start with 'P', followed by 8 digits ranging from 0 to 9.P12345678
P12345
P-12345678
P12345678
[not recognized]
[not recognized]
[FR]-[0-9]{3,}The field value must start with either 'F' or 'R' and '-', followed by at least 3 digits ranging from 0 to 9.R-123
F-12345
F-1234567
O-7611
R-123
F-12345
F-1234567
[not recognized]
[FR]-[0-9]{3,5}The field value must start with either 'F' or 'R' and '-', followed by 3 to 5 digits ranging from 0 to 9.R-123
F-12345
F-1234567
O-7611
R-123
F-12345
[not recognized]
[not recognized]
I[0-9]{8}The field value must start with 'I', followed by 8 digits ranging from 0 to 9.I12345678
I12345
I-12345678
I12345678
[not recognized]
[not recognized]
INV[0-9]{5}X[0-1]{1}The field value must start with 'INV', followed by 5 digits ranging from 0 to 9, then 'X', followed by 1 digit ranging from 0 to 1.INV12345X1
INV12345X2
INV12345H1
INV12345X1
[not recognized]
[not recognized]
<>ABC&<>DEFThe field value must be different from 'ABC' and 'DEF'.ABC
DEF
GHI
[not recognized]
[not recognized]
GHI
Invoice|Credit MemoThe field value must be either 'Invoice' or 'Credit Memo'.Invoice
Credit Memo
Credit Note
Invoice
Credit Memo
[not recognized]
*AY*The field value must contain the letters 'AY'.AY
DAYS
WEEKS
AY
DAYS
[not recognized]

Using rules in line fields

When using rules in line fields, you can filter which values should be kept and which should remain blank. When combined with the Required checkbox, this enables you to include only lines with certain content – or leave out lines that otherwise would conflict with the line structure in the document.

To add a rule to a line field:

  1. Choose the Search icon, enter Document Categories, and then choose the related link.
  2. Select the PURCHASE code to open the document journal.
  3. In the list of documents, select the document whose template field you want to set up a rule for.
  4. In the Lines section, select the three dots by the value of the line field you want to set up a rule for.
  5. In the action bar, select Rules. Alternatively, you can edit the Rule field on the General FastTab.

Below are some examples of regular expressions that can be used in line fields, as long as these fields are marked as required or line recognition is using AI. Otherwise, the field value is skipped – but the rest of the line is still recognized.

ExpressionDescription
InvoiceRecognize lines where the field value is 'Invoice'.
Invoice|Credit MemoRecognize lines where the field value is either 'Invoice' or 'Credit Memo'.
<>SubtotalSkip lines where the field value is 'Subtotal'.
<>Freight*Skip lines where the field value begins with the word 'Freight'.
<>*A*&*E*Skip lines where the field value contains the letter 'A' and only recognize lines where the letter 'E' is present.
POS[0-9]{3}Recognize lines where the field value starts with 'POS' followed by 3 digits.
[a-z ]{10,20}panelRecognize lines where the field value has 10-20 characters, contains letters and spaces, and ends with 'panel' – though 'panel' doesn't count toward the character limit.

Using automatically generated rules

Instead of manually entering rules for each template field that requires them, it's possible to let Document Capture generate rules based on the captured values. If the format of a captured value for a field changes, Document Capture generates a new rule to match the latest format.

To enable rule generation:

  1. Choose the Search icon, enter Document Categories, and then choose the related link.
  2. Select the PURCHASE code to open the document journal.
  3. In the list of documents, select the document whose template field you want to set up a rule for.
  4. In the Document Header section, select the three dots by the header field you want to set up a rule for. Alternatively, in the Lines section, select the three dots by the value of the line field you want to set up a rule for.
  5. On the General FastTab, turn on the Enable Rule Generation setting.

Bemærk

It’s only possible to enable automatic rule generation for template fields with the data type set to Date or Text.

Tip

To capture only the part of the value that matches a certain rule, such as digits but no letters or special characters, use the Capture Only Match feature. For more information, see To capture only the parts of values that match a specific rule.

Resources

The following resources are useful when building or tweaking regular expressions:

  • Microsoft Copilot – or an equivalent generative artificial intelligence chatbot. These tools are good at creating and testing custom rules, but make sure to double check their output.
  • RegExr - a tool to help you build and test regular expressions.
  • Regex101 - another tool to help you build and test regular expressions.