How to use Expression Builder with a 'where' formatter

Hello,

I want to add a conditional region based on a condition that includes where formatter as below

<div is="dmx-if" dmx-bind:condition="sc_list_scope_activities_agriculture.data.q_list_scope_activities.where(`activity_title`, 'Fertilizer', 'contains')">

However, the above code doesn't work correctly. When I open the Expression Builder, this is how the expression appears under the code tab.

sc_list_scope_activities_agriculture.data.q_list_scope_activities==`activity_title`

Is it possible to build an expression with a where clause?

Hello, there is a where formatter available and it generates the code correctly:

Hi Teodor,

The where formatter can be selected. However, this code is generated in the Expression Builder, and it doesn't work. What should I select instead of isEmpty()?

<div is="dmx-if" dmx-bind:condition="sc_list_scope_activities_agriculture.data.q_list_scope_activities.where(`activity_title`, 'Fertilizer', 'contains').isEmpty()">

Are you using the where formatter or the filter formatter?

because when using the where formatter you don't get this UI, but the one i posted in my previous reply.

I'm using the where formatter. I have made a short video showing how Expression Builder adds the formatter isEmpty() when where formatter is selected.

I don’t really understand what you’re doing. Either select the expression and use the filter formatter, or use the where formatter. You’re calling the where formatter inside the value of the filter formatter—that’s not how it’s supposed to work.

In the value, pick your dynamic value, then select “contains” from the dropdown, and enter the value like this:

In your case you want to use the where formatter directly.

When I used the Expression Builder with contains formatter, the expression was added with an index [0] that wouldn't have evaluated all possible values from the database. That was the reason I wanted to use where formatter, which obviously didn't comply with the Expression Builder's code formatting.

is="dmx-if" dmx-bind:condition="sc_list_scope_activities_agriculture.data.q_list_scope_activities[0].activity_title.contains('Fertilizer')"

I have changed how I'm evaluating the condition now.

Thanks for your help, Teodor.