Skip to content

view.Filters

Overview

"Filter" of the "view object". By "Filter" the "records" displayed in the "Screen Index" or "Editor" with "Server Script", you can limit the records that users can view. Unlike "Record Access Control", there is no need to set access rights for each "Record". "JSON Data Layout: View" can be used.

Limitations

  1. Only the "When Processing View" condition can be used.
  2. "Attachment Column" and "Comment Column" cannot be used.
  3. The "Filter" operation on the "Screen Index" does not work for column for which filters have been set using "Server Script". They will be overwritten by "Server Script".
  4. Search results may differ when using SQL Server and PostgreSQL. SQL Server uses the LIKE clause or full text search, while PostgreSQL uses the ILIKE clause or full text search using pg_trgm.

Cautions

  1. Even if you use the view.Filters function to filter records so that they are not extracted on the list screen, they will still be displayed in the search results index in "Cross Search". To prevent this, you must disable cross-search in the Manage table settings "Disable Cross Search".

Properties

No Property name Change Description
1 [Column Name] ○ Specify the "Column Name" to apply the "Filter" to and set the filter string.

Methods

There are no methods.

Usage Examples

① In the example below, records with a "Status Column" of 900 (Completed) or 910 (Pending) are extracted and displayed.

JavaScript
view.Filters.Status = '["900","910"]';

In the example below, records with "User" IDs 215 and 319 set in the "Owner Column" will be extracted and displayed.

JavaScript
view.Filters.Owner = '["215","319"]';

In the example below, records with numerical values ​​set in the "Numerical Value Column" between 600000 and 700000 will be extracted and displayed. If you omit the part before the comma, records with values ​​below 700000 will be extracted and displayed, and if you omit the part after the comma, records with values ​​above 600000 will be extracted and displayed. To search for multiple ranges, specify '["100000,200000","600000,700000"]'.

JavaScript
view.Filters.NumA = '["600000,700000"]'

In the example below, records, where the date set in the "Date Column" is today, will be extracted and displayed. '["Today"]' will extract today, '["ThisMonth"]' will extract this month, and '["ThisYear"]' will extract this year.

JavaScript
view.Filters.DateA = '["Today"]';

In the example below, records with dates set in the "Date Column" between 2021/5/1 00:00:00 and 2021/5/31 23:59:59.997 will be extracted and displayed. If you omit the part before the comma, records with dates before 2021/5/31 23:59:59.997 will be extracted and displayed, and if you omit the part after the comma, records with dates after 2021/5/1 00:00:00 will be extracted and displayed. To search multiple ranges, specify '["2021/1/1,2021/1/31 23:59:59.997","2021/5/1,2021/5/31 23:59:59.997"]'.

JavaScript
view.Filters.DateB = '["2021/5/1,2021/5/31 23:59:59.997"]'

In the example below, records with the "Check Column" checked will be extracted and displayed. Assigning false will extract records with the column checked.

JavaScript
view.Filters.CheckA = true;

In the example below, records containing the word "Software" in the "Body Column" column will be extracted and displayed. By setting the "Search Type" in the "Filter" of "Manage Table", you can perform not only a "Partial Match Search", but also a "Prefix Match Search" and "Exact Match Search". Similar searches can also be performed in "Title Column", "Description Column", and "Class Column" with no options.

JavaScript
view.Filters.Body = 'software';

In the example below, records where the "Status Column" is 900 (Completed) and the date set in the "Date Column" is today will be extracted and displayed. If multiple columns are set, they will be "Filter" using the AND condition.

JavaScript
view.Filters.Status = '["900"]';
view.Filters.DateA = '["Today"]';

In the example below, records with "Status Column" set to 900 (Completed) or "Class Column" set to "Design" will be extracted and displayed. You can "Filter" using OR conditions by assigning a filter condition in JSON format to any property that begins with "or_". You must explicitly disable the "filter" operation from the screen.

JavaScript
// Disable filter operations from the screen
view.Filters.ClassA = '';
view.Filters.Status = '';
// Setting an OR condition
let data = {};
data.Status = '["900"]';
data.ClassA = '["design"]';
view.Filters.or_MyFilterName = JSON.stringify(data);

In the example below, when accessed by a user with department ID 3, records with HR set as a option for "Class Column" are extracted and displayed. When accessed by a user with department ID 7, records with Development set as a option for "Class Column" are extracted and displayed. When accessed by a user from any other department, all records are extracted and displayed.

JavaScript
context.Log(context.DeptId);
switch (context.DeptId) {
    case 3:
        view.Filters.ClassA = '["personnel"]'
        break;
    case 7:
        view.Filters.ClassA = '["development"]'
        break;
    default:
        break;
}

In the example below, if a user other than user ID 2 accesses the page, records where ClassA is Design and ClassD is 3, or records where ClassB is Testing and ClassD is 7 will be extracted and displayed. If a user with user ID 2 accesses the page, all records will be extracted and displayed. By assigning a filter condition in JSON format to any property beginning with and_, you can perform a "Filter" that combines OR conditions and AND conditions.

JavaScript
if (context.UserId !== 2) {
    let data1 = {};
    data1.ClassA = '["design"]';
    data1.ClassD = '["3"]';
    let data2 = {};
    data2.ClassA = '["test"]';
    data2.ClassD = '["7"]';
    let data = {};
    data.and_Filter1 = JSON.stringify(data1);
    data.and_Filter2 = JSON.stringify(data2);
    view.Filters.or_Filter = JSON.stringify(data);
}

In the example below, records with Nakano-ku, Tokyo set in ClassB of the record of site ID 6 linked with ClassA will be extracted and displayed. The following description allows you to filter by the column of the master record.

view.Filters['ClassA~6,ClassB'] = 'Nakano Ward, Tokyo';

In the example below, records that have System Development set in ClassB of child records of site ID 7 linked by ClassA are extracted and displayed. The following description allows you to filter by child record column. If multiple child records are found, multiple records with the same parent record will be displayed.

view.Filters['ClassA~~7,ClassB'] = '["System Development"]';

In the example below, only records where the value of ClassA matches the value of ClassB will be extracted and displayed. By specifying the column to compare in the format of '{first column}|{second column}' for any property starting with eq_, you can filter out only records where the values ​​of the two columns match.
*However, you cannot specify columns with different data types for the two columns. The data type of each column is listed in the list of Correspondence between column names and "Column Name" in the database.

JavaScript
view.Filters.eq_MyFilterName = 'ClassA|ClassB';

In the example below, only records where the values ​​of ClassA and ClassB do not match will be extracted and displayed. By specifying the column to compare in the format '{first column}|{second column}' for any property starting with notEq_, you can filter out only records where the values ​​of the two columns match.
*However, you cannot specify columns with different data types for the two columns. The data type of each column is listed in the list of Correspondence between column names and "Column Name" in the database.

JavaScript
view.Filters.notEq_MyFilterName = 'NumA|NumB';

Properties beginning with eq_ and notEq_ can be used in combination with properties beginning with or_ and and_. You can also specify the fields of the linked parent record. In the example below, only records where "the title of the record with site ID 10 linked with ClassA matches the value of ClassB" or "the value of NumA of the record with site ID 10 linked with ClassA matches the value of NumA" are extracted and displayed.

JavaScript
let data = {}
data.eq_Filter1 = 'ClassA~10,Title|ClassB';
data.eq_Filter2 = 'ClassA~10,NumA|NumA';
view.Filters.or_MyFilter = JSON.stringify(data);

Supported Versions

"Filter" with OR Conditions

  1. Pleasanter 1.1.14.0 or later
  2. Pleasanter .NET Framework version 0.50.220 or later

"Filter" with AND Conditions

  1. .NET Core version 1.1.28 or later
  2. .NET Framework version 0.50.252 or later

"Filter" with Match/Non-Match Conditions

  1. .NET Core version 1.3.18.0 or later
  2. .NET Framework version 0.51.18.0 or later