> ## 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.

# Sample 3. Step 4: Analyzing the images to decide in which order elements must be detected

> Plan the element search order for the invoice FlexiLayout in Sample 3: analyze field arrangement and outline the InvoiceHeader group and its elements.

At this step, decide the following:

* Is there any pattern in the arrangement of the fields on the images?
* Which elements can be used as reference elements for field detection?
* Which element search order is the best choice? (At each new step, you can only refer to previously described elements.)

Analyze the available images.

1. You will have noticed that the central part of the document contains a table which occurs on all the images.

   <Info>
     In FlexiLayout Studio, a table is an image object made up of fragments that consist of rows and columns visually separated by separator lines or by white gaps. For more information, see [Work with tables](/flexi-capture/fls/tables/general-tables).
   </Info>

2. Above the table there is a group of fields (which may be named the InvoiceHeader): **Invoice Number**, **Invoice Date**, and **Delivery Address**. Note that the field **Invoice Number** occurs on all the images and can be used as an identifier field, while the fields **Invoice Date** and **Delivery Address** are optional.

3. Below the table there is a group of fields (which may be named the Footer): **TotalQuantity**, **TotalAmount** and **Country**. These fields also do not occur on all the images.

Start by describing the search for elements in the upper part of the document. To detect the upper fields, create a logical group that unites all the elements used to look for the fields Invoice Number, Invoice Date, and Delivery Address.

1. Create an element of type [Group](/flexi-capture/fls/template/elements-compound) and name it **InvoiceHeader**.\
   The fields **Invoice Number**, **Invoice Date**, and **Delivery Address** are always located in the upper left corner. Moreover, their order is always the same: **Delivery Address** followed by **Invoice Number** followed by **Invoice Date** (provided they occur on the image). Look for them in the same order.
2. To describe the search for the keywords of the field names **Invoice Number**, **Invoice Date**, and **Delivery Address**, use elements of type [Static Text](/flexi-capture/fls/template/static-text). The **InvoiceHeader** element must contain the following elements:
   * **kwDeliveryAddress** element of type [Static Text](/flexi-capture/fls/template/static-text), which will correspond to the name of the field **Delivery Address**. For detailed instructions, see [Step 5](/flexi-capture/fls/tutorial3/3step5).
   * **kwInvoiceNumber** element of type [Static Text](/flexi-capture/fls/template/static-text), which will correspond to the name of the field **Invoice Number**. For detailed instructions, see [Step 6](/flexi-capture/fls/tutorial3/3step6).
   * **kwDate** element of type [Static Text](/flexi-capture/fls/template/static-text), which will correspond to the name of the field **Invoice Date**. For detailed instructions, see [Step 7](/flexi-capture/fls/tutorial3/3step7).
3. Search for the fields **Invoice Number** and **Invoice Date** in the same row as their corresponding names, to the right of the names.\
   In the **InvoiceHeader** element, create the following elements:
   * **InvoiceNumber** element of type [Character String](/flexi-capture/fls/template/character-chain), which will correspond to the field **Invoice Number**. For detailed instructions, see [Step 8](/flexi-capture/fls/tutorial3/3step8).
   * A [Group](/flexi-capture/fls/template/elements-compound) element **grDate** to look for the field **Invoice Date**. For detailed instructions, see [Step 9](/flexi-capture/fls/tutorial3/3step9).

In the `InvoiceHeader.grDate` element, create:

* **InvoiceDate** element of the [Date](/flexi-capture/fls/template/date) type, which will correspond to the **Invoice Date** field in the case of good quality images. For detailed instructions, see [Step 9](/flexi-capture/fls/tutorial3/3step9).
* **InvoiceDateAsString** element of type [Character String](/flexi-capture/fls/template/character-chain), which will correspond to the **Invoice Date** field if the program fails to find the **InvoiceDate** element. For detailed instructions, see [Step 9](/flexi-capture/fls/tutorial3/3step9).

  <Note>
    For more information on finding dates on poor quality images, see the [Tips and Tricks](/flexi-capture/fls/tips-tricks/date2) section.
  </Note>

1. The field **Delivery Address** has multiple lines, so an element of the [Paragraph](/flexi-capture/fls/template/text-chain) type is needed to detect it. However, before creating this element, limit the search area as much as possible. For the right boundary of the search area, use an element of the [White Gap](/flexi-capture/fls/template/white-gap) type. Then group all the elements that describe the location of the field **Delivery Address** into a [Group](/flexi-capture/fls/template/elements-compound) element:
   * In the element **InvoiceHeader**, create a Group element and name it **grAddress**. For detailed instructions, see [Step 10](/flexi-capture/fls/tutorial3/3step10).

In the **grAddress** element, create the following elements:

* An auxiliary element **wgAddressRight** of the [White Gap](/flexi-capture/fls/template/white-gap) type, which borders the field **Delivery Address** on the right. For detailed instructions, see [Step 11](/flexi-capture/fls/tutorial3/3step11).
* An element **DeliveryAddress** of the [Paragraph](/flexi-capture/fls/template/text-chain) type, which will correspond to the field **Delivery Address**. For detailed instructions, see [Step 12](/flexi-capture/fls/tutorial3/3step12).
