Segment filter 'contains' instead of 'including'

Your software
My Mautic version is: 4.1.1
My PHP version is: 7.4
My Database type and version is: tidb

Your problem

I have a custom field ‘industries’ on a company. It is multiselect. It has values like ‘Utilities’, ‘Consumer Goods’ etc.

I wish to create a segment that selects leads whose company.industries is in a list.
I can select a single value ('company.industries including Utilities).
But, if i set 2 values, it has the logic of “is all of the values”, and i would like to use “Is at least one of the values”.

Is there anyway to do this? the segment filter only has including/excluding.

talks of this. is there a method to do ‘contains’?

1 Like

I had the same problem and I changed the code in these 3 points changing the previous expr()->and with expr()->or an the multiselect works as “is at least one of the values”:

<your_path>/app/bundles/LeadBundle/Entity/LeadFieldRepository.php (ROW=289): $expr = $expr->with($q->expr()->or(...$andExpr));
<your_path>/app/bundles/LeadBundle/Segment/Query/Filter/ComplexRelationValueFilterQueryBuilder.php (ROW=119): $expression = $queryBuilder->expr()->or(...$expressions);
<your_path>/app/bundles/LeadBundle/EventListener/SegmentOperatorQuerySubscriber.php (ROW=117): $event->addExpression($event->getQueryBuilder()->expr()->or(...$expressions));

Hope this could help.

PS: remember to delete the cache
rm -rf <your_path>/var/cache/prod