Question

Creating a Custom Lookup Filter with Complex Conditional Logic

Hello Creatio Community,

I’m trying to implement a custom filter for a contacts dropdown on my mini page, and I need help constructing it properly.

The filter has two main conditions combined with AND:

  1. The first condition itself has two sub-conditions depending on whether a certain column is null or not:
    • If the column is not null, get a string value from the related column1id table and compare it with the contacts.
    • If the column is null, get an ID value from the related column2id table, then use that ID to retrieve a string for comparison with the contacts dropdown.
  2. The second condition involves a specific field ID:
    • Use this ID to filter contacts who have a checkbox selected that corresponds to this ID.

How would you tackle retrieving data from data source? How can I build a filter that applies these conditions properly with AND logic between them? 

 

Edit: Question no.  2:
Would it be possible to do all the filtering logic in JS (manually send a query to the database) and somehow push the result to the dropdown as datasource?

Like 8

Like

3 comments

Hello,

Could you please clarify if you are setting up a Business rule or an advanced filter in a group/folder?

Mira Dmitruk,

Hello,

I am creating a filter using JavaScript in the page Source Code. Something similar to this, but more complex filter logic with JOIN to more than one tables:
Filtering a lookup in Freedom UI - Help needed | Community Creatio

I am also wondering, would it be possible to do all the filtering logic in JS (manually send a query to the database) and somehow push the result to the dropdown as datasource?

Hello! You don’t need to replace the lookup’s datasource — the recommended way in Freedom UI is to intercept the lookup load, read any helper values you need with the SDK’s Model class, and then add your filter before the query runs. That way you can check whether column1id is null, fetch the right string from the related table, and combine it with an EXISTS filter to only return contacts with the right checkbox set. Both conditions go into the same filter group so they apply together.

Show all comments