Axelor Doc

Requests to these servers

Queries are defined in the tag <select> . They can be multiple. In this case, repeat the tag <select> as many times as objects to be displayed in the search view.

Each tag <select>, must specify on the object on which we did the research, the attribute model = "" and a label, the attribute title = "". The tag <select> define search criteria by object and maps the fields of the object in the result fields.

Example search on a Partner object:

<select model="com.axelor.sale.db.Order" title="Sale Order" orderBy="date,-value" >

Results can be sorted by tag orderBy which takes as parameter fields of the object on which we did the research, separated by commas.

Inside the tag <select> you can use the following tags:

  • <field> allows you to link a field of the object (the tag name ) to result fields (by the tag as )
  • <join> allows a join. Used on M2M fields such it enables you to search the contents of table rows.
  • <where> defines the conditions. You can use the full name to match each field value of the graphic object. If the path of the field is a multi-valued (O2M / M2M), it must be suffixed with [] (for example, items []. product ). This tag must define the operator to use between tests that follow with the option game :
    • all : (the operator is AND) Must meet all criteria
    • any: (the operator will be OR) Must meet at least one criteria

Inside the <where> tag is used <input> . each test

Example: Search records where the field contactName of the object shown in the tag <select> contains ( contains ), which was entered in the criterion name .

<input name="name" field="contactName" matchStyle="contains"/>

Possible values matchStyle option:

  • contains - if the field value contains the input value given
  • startsWith - if the field value begins with the input value given
  • endsWith - if the value of the field ends with the input value given
  • equals - if the field value is equal to the input value (default)
  • notEquals - if the field value is not equal to the input value
  • lessThan - if the field value is smaller than the input value
  • lessOrEqual - if the value of the field is less than or equal to the input value
  • greaterOrEqual - if the field value is greater than or equal to the input value

Tags <select> and <input> can have an optional requirement embodied by the tag if that can contain any boolean expression Groovy to evaluate the input values. If the result of the expression is false, then these elements are omitted.

Clause where is reconstructed from XML attributes match = "any | all" corresponding to OR and AND. All records corresponding to an element input given are returned even if the game uses attribute is all . (Note 1)

Note 1: If the tag <input> is used several times on the same test, the operator is automatically used OR. This happens in the following example with the standard phone :

<input name="telephone" field="contactFixedPhone1" matchStyle="contains"/>
<input name="telephone" field="contactMobilePhonePerso"

Example:

<select model="com.axelor.sale.db.Order" title="Sale Order" orderBy="date,-value">
    <field name="customer.fullName" as="customer"/>
    <field name="items[].product.name" as="product"/>
    <field name="createDate" as="date"/>
    <field name="amount" as="value"/>
    <where match="all">
        <input name="customer" field="customer.fullName" matchStyle="contains"/>
        <input name="customer" field="customer.email" matchStyle="contains"/>
        <input name="date" field="createDate"/>
        <input name="product" field="items[].product"/>
    </where>
</select>

The result of this research led to the following JPQL query:

SELECT
    _customer.fullName AS customer,
    _items_product.name AS product,
    self.createDate AS date,
    self.amount AS value
LEFT JOIN self.customer AS _customer
LEFT JOIN self.items AS _items
LEFT JOIN _items.product AS _items_product
WHERE
    (_customer.fullName LIKE :customer OR _customer.email LIKE :customer) AND (self.createDate = :date) AND (_items.product = :product)
ORDER BY
    date, value DESC

Note : Note that the relational fields joined with the LEFT JOIN to include NULL records so that the game does not affect any records.