> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Use instances of a Repeating Group as reference, excluded, or source elements

> Reference Repeating Group instances such as LastFound, AllInstances, Instance(#), and CurrentInstance when defining relations and excluded elements.

You can use the element selection dialog box to select:

* A reference element on the **Relations** tab of an element's **Properties** dialog box
* An excluded element on the **Search Constraints** tab of an element's **Properties** dialog box
* A **Source element** in a block's **Properties** dialog box

For simple elements, their names are used. For a **Repeating Group** element, a reference to the hypotheses for the repeating group (taking into account the number of the instance) is used to create relations.

When matching a FlexiLayout, several instances of hypotheses for the repeating group will correspond to one **Repeating Group** element in the tree of elements. Therefore, when specifying relations between a Repeating Group and other elements, you must specify which instance should be used. When you specify a reference to a hypothesis rather than a full name, the name of the Repeating Group is followed by a full stop and a description of the referenced instance.

## Repeating Group instance types

An instance can be one of the following:

| Name                | Description                                                                                                                                                                                                                                                             |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **LastFound**       | The last detected instance of the Repeating Group at the moment when a hypothesis is generated for the given subelement.                                                                                                                                                |
| **AllInstances**    | All the detected instances of the Repeating Group.                                                                                                                                                                                                                      |
| **Instance(#)**     | A particular instance number.                                                                                                                                                                                                                                           |
| **CurrentInstance** | The current instance. Used when specifying relations for a subelement of a Repeating Group, to refer to the current hypothesis for the group itself, that is, to the already detected subelements of the group that are located above the given subelement in the tree. |

## Reference syntax

The syntax of the reference in the element selection dialog box is the same as the syntax used in the code you type in the **Advanced** sections to access the instances of a **Repeating Group** and their subelements.

For example:

```text theme={null}
SearchElements.RepeatingGroup.LastFound.RepeatingGroup1.Instance(1).StaticText
```

## Select an instance in a dialog box

An instance of a group is selected in the dialog boxes where you select a reference element or an excluded element. In the selection tree, the instance numbers are indicated next to the names of repeating groups. When you select a **Repeating Group**, a **Repeating instance** field becomes available, where you can select the instance. The changes you make will be reflected both in the tree and in the result string.

## Rules for CurrentInstance and AllInstances

When you select **CurrentInstance** for a child group, **CurrentInstance** is automatically set for all the groups above it. If you change the **CurrentInstance** of a parent group to something else, the instances of all the child groups will be reset to the default value of **LastFound**.

When you select **AllInstances** for a parent group, **AllInstances** is automatically set for all the child groups. If you change the **AllInstances** of a child group to something else, the **AllInstances** of the parent groups will be reset to the default value of **LastFound**.

When creating a reference manually in the Advanced code, keep in mind that **CurrentInstance** can only be specified for a parent group, and if you specify **CurrentInstance** for a group, all the groups above it must also have **CurrentInstance** specified for them. If **AllInstances** is specified for a group, all the groups below it must also have **AllInstances** specified for them. When you select group instances in the dialog box, the correct values are enforced automatically.

## Related topics

* [Search constraints](/flexi-capture/fls/template/basic-constraints)
* [Relative search area](/flexi-capture/fls/template/relations)
* [Additional search constraints](/flexi-capture/fls/template/advanced-constraints)
