Skip to main content

Filtered View - Filter Expression

When you define the view, you should put the 'Filter Expression' in json format.

Lookup - My documents in filtered view with Lookup (Select, Typehead, Dropdown) relation - as Filter Expression in view

return [{
key: 'recruiterId.id',
value: [Me]
}];

recruiterId - is the key for Recruiter attribute, of Select type which appoints the person. Such defined filtered view will show only the documents in where my user is assigned as Recruiter.

Multi-select - My documents in filtered view with Multi-select relation - as Filter Expression in view

return [{
key: '_id_performsRecruitment.'+[Me],
value: true
}];

In this case there is placed on the form the multiselect type attribute with the key performsRecruitment . It returns as example - when 2 persons are appointed:

[
{
"objectTypeId":"person",
"classId":"gwZ83NWTFFPMuw2Ii1em",
"id":"92OEWfCoP3jWciNR9XkL",
"name":"Aaron Burden"
},
{
"id":"dr0qWgrhztq2f5036crz",
"objectTypeId":"person",
"name":"Jim Smith",
"classId":"person_class"
}
];

In this case we are using, by applying the above filter code, additionally created by the system key:

_id_performsRecruitment: {
92OEWfCoP3jWciNR9XkL: true,
dr0qWgrhztq2f5036crz: true
}

and it's created subkeys (whether the one exists for your user with true value) like: _id_performsRecruitment.92OEWfCoP3jWciNR9XkL, _id_performsRecruitment.dr0qWgrhztq2f5036crz

A few keys filter - type of the task is meeting (Select) and I am involved in participants (Multi-select)

return [{
key: '_id_membersOfInterview.'+[Me],
value: true
},
{
key: 'typeRecTask.id',
value: '02INTERVl5quZl3v5uuI'
}
];

Used as alternative (filtered view) in tasks in Recruitment module (Class Filtered View 'I PARTICIPATE').

Number - documents with number key equal to value

return [
{
key: 'plannedWeek',
value: '10'
}
];

PS. After adding Number type of attribute without any value expressionn it is stored in database as text.

Number - documents with number key less than the value

There is recommended to be deployed data preparation scenario. Deploy the Boolean type flag with the Value Expression which is depending on the Number types attribute. Boolean will return true or false and the filter to the view will be applied for this boolean type attribute.

Example case: show in separate view only the recruitments when plannedWeek attribute (means planned week for hiring of the candidate) is less than 12 week of the year.

On recruitment form there is 'Planned Week' Numeric type attribute:

First there is deployed Boolean type attribute ifBelow12

with the expression:

const amount = ${plannedWeek}; 
if (amount < 12) {
return true;
}
else
{
return false;
};

In the case Planned Week is less than 12, it returns true. Otherwise it returns false.

Next step is to deploy filtered view with the following expression:

return [
{
key: 'ifBelow12',
value: true
}
];

ifBelow12 is the key for the boolean type attribute ifBelow12. The view shows up only these recruitments which has this flag marked (auto calculated by expression from Planned Week):

So the only 1 of 2 documents is presented in above view; all docs:

Number - documents with number key greater or equal to the value

Please review previous example before further reading as it is analogical example. The filter is basing on the same boolean type attribute ifBelow12. But it is setup for the reverse false value:

return [
{
key: 'ifBelow12',
value: false
}
];

It shows up the documents which planned week is greater or equal to 12th week of the year:

PS. Implementation of 'If After 12 Week' attribute (appearing on screenshots for illustrative reasons) is not recommended from performance reasons. It is good enough to deploy only boolean type attribute ifBelow12 with expression.

Filtered View Definition

Filtered views