Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The reThe filter mission is used to limit the set of records that will to be displayed in the list (in any list: related list, open list, the dictionary). The filter is a set of conditions sets certain conditions for the record must to meet to be on in the list. Filters can be configured with the Condition Builder.

For example, we need to filter users living in Sevastopol. In  In SQL, we use the WHERE clause operator to filter records.

Tip

You can add a filter with all necessary filters in your Favorites in the Navigation menu.

To do this, drag and drop the breadcrumbs to the Favorites navigation tab.

Filter

Filters

components


Filters consist of the following components:

  1. Condition builder (and the breadcrumbs as its integral part);.
  2. Search and sorting:
    1. Input field at the top of every column is used for searching;.
    2. Click on the column title to sort the search results.
  3. Filter outOut/show matching Show Matching (this item can be found in the context menu, to open it, right-click on the list cell).

All these components form the condition string, which is sent in the request as a GET parameter, and the filtered list of records will be returned and displayed.


The difference between condition builder on lists and regular condition builder is that breadcrumbs and sorting functionality added.

Breadcrumbs allow assessing the filter visually; also. Also, they allow quick filter editing by navigation to the condition specified.

Sorting allows adding its conditions (ascending or descending) on one or more list fields.

How

the filter works

filters work


For more clarityTo be more visual, let's take an example.

We need to find Alexander Egorovfind John Doe's closed tasksrequests, sorted by priority.

For this, we will create such a filter on the task Request list (the task itsm_request table):

Image RemovedImage Added


After that. , condition string can be found in the condition GET parameter: 

Code Block
languagejs
themeEclipse
titleGET
/list/task?condition=(((state=4^ORstate=5)^assigned_userLIKEAleksandr%20Egorov))^ORDERBYprioritystate%3D-2%5EdescriptionISEMPTY%5Epriority<3)

The condition string elements more closely:

ElementDescription
(state=4^ORstate=5)State = 4 or State =5 (Closed Complete or Closed Incomplete)subjectISNOTEMPTYSubject is not emptyassigned_user.username=aleksandr_egorovUsername = Alexander Egorov^ORDERBYpriorityRecords will be sorted by the priority fields in the ascending order.
state%3D-2State is Registered
descriptionISEMPTYDescription is not set
priority<3Selection will contain records with Priority value less that 3 (Moderate and Low)
%5EORDERBYDESCpriorityRecords will be sorted by the Priority field in descending order.

Encoding and decoding queries

To decode an encoded query string storing the condition obtained from the GET parameter, we recommend using the addEncodedQuery and getConditionQuery methods of the SimpleRecord Server-Side class. You can decode the encoded string by completing the simple steps:

  1. Perform a selection against the table list view using a Condition Builder.
  2. Copy the condition from the URL as shown on the screenshot below:
    Image Added
  3. Navigate to System Settings → System Scripts and click New.
  4. Fill in the Script field with code below (this one is given for example):

    1. Fill in the {tableName} placeholder with the table system name.

    2. Fill in the {conditionQueryCondition} placeholder with the copied condition.
    3. Click Run to execute the script.
Code Block
languagejs
themeEclipse
titleDecode encoded query
linenumberstrue
const current = new SimpleRecord('{tableName}');
current.addEncodedQuery('{conditionQueryCondition}');
ss.info(current.getConditionQuery());
// Info: (state=-2^descriptionISEMPTY^priority<3)


Note

Filtering for the fields of the Reference, List, ChoiceRecord Class and Field Type Nametypes has some nuances related to the value and default display_value fields correlation in  in tables:

  1. Filtering is performed by the value of the value field. For example: in case the case of filter condition is field_name = value,   then displayed condition will be field_title = display_value.
  2. Column search is performed by the value of the display_value field; either the filter or the breadcrumbs on the filter top above it are filled with the condition field_name = value; at the time, the condition displayed is field_title = display_value.
  3. The autosuggest auto-suggest functionality is performed by either value or display_value field values.

The table below can clarify the filtration specifics when doing the selection with field of types above involved.

Column typeOperatorSearch field
ReferenceLIKE / NOTLIKE / STARTSWITH / ENDSWITHdisplay_value
ListLIKE / NOTLIKEdisplay_value
ChoiceLIKE / NOTLIKE / STARTSWITH / ENDSWITHtitle
Record ClassLIKE / NOTLIKE / STARTSWITH / ENDSWITHtitle

See the Condition Operators article to obtain filter operators full list.

Dynamic Filters


Dynamic filters extend the filters by the JS scripts executing ability. This ability is available in the list condition builder and in the dynamic reference qualifier condition builder.

In Condition Builder, dynamic filters are available when selecting the reference field and the 'Is is (dynamic)' or similar similar operator. After this, the list of available dynamic filters will appear.

When executing the filter as a value of the condition using the 'is dynamic' operator, the value returned by the dynamic filter script will be used.

To create a new dynamic filter, please complete the following steps (a new record in the Filter Option Dynamic (sys_filter_option_dynamic) table will be created):

  1. Navigate to to System Definition → Settings → Dynamic Filters;.
  2. Click New , fill in the form and then click Saveand fill in the fields.
  3. Click Save or Save and Exit to apply changes.
Info

You can also create dynamic filters for table fields of the sys_id type (ID). To do that, specify the dynamic filter form fields in the following way:

  1. In the Column type, select biginteger Big Integer from the list.
  2. In the Reference table, specify the table to apply this filter on.
  3. Set the Active checkbox checked.
  4. Set the Available for filter checkbox checked.
  5. Complete filling the form and click Save.

To apply the dynamic filter created, specify the ID table column and the is (dynamic) operator as the Condition Builder field and operator appropriately.

Dynamic filters form fields

FieldMandatoryDescription
TitleYThe filter title.
ActiveSelect this checkbox to make the filter active.Column type
Column TypeN

The column type used in

the

this filter. This field references to the Columns dictionary.

OrderEnter the number to define the order of filter processing.Referenced table
Note

The Reference Qualifier tab is available only for field of Reference or List types. For fields of other types, use Condition Builder Options.


Referenced TableYChoose the table to apply this filter on.
Available for
filter
FilterNSelect this checkbox to make this filter available in the filters list
filters
.
Available for
reference qualifier
Reference QualifierNSelect this checkbox to make this filter available for a dynamic reference qualifier.
ActiveNSelect this checkbox to make the filter active.
OrderNEnter the number to define the order of filter processing.
ScriptYEnter the script that the dynamic filter runs.
 You
 You can use all methods
of 
of server-side API
 classes
 classes here. After executing, the script should return the record ID or array of IDs.


Table of Contents
absoluteUrltrue
classfixedPosition