Hi @bandtank
The filters allow you to have primary filter on list view of certain entity. it is powerful way to filter data based on conditions also you can add more user restrictions if you wish to. using advanced pack you can build filter reports but i prefer to use these custom filters as i can use them on dashlets as well. you can find the whole process of creating custom filters on this blog post here https://devcrm.it/custom-filters
i hope you find it helpful if you need it in future.
Custom primary filter for multi-enum
Collapse
X
-
Thanks. That helps a lot, actually. I don't see a need for primary filters after looking at the code in the repository because the advanced pack allows reports to be used as filters. It's good to know how to do it, though.first Hi, (with my poor english)
https://github.com/espocrm/espocrm/b...s/Account.json
in metadata you declare wich and where you select class is
then in path of rabii have posted, you implement ...
and for language file.. i don't know but easy to find..
I use on github "search/find" .. and try to replicate -
first Hi, (with my poor english)
EspoCRM – Open Source CRM Application. Contribute to espocrm/espocrm development by creating an account on GitHub.
in metadata you declare wich and where you select class is
then in path of rabii have posted, you implement ...
and for language file.. i don't know but easy to find..
I use on github "search/find" .. and try to replicate
Leave a comment:
-
I do not know what to do with the information at that link. I found it, but how is it implemented? Which files? The information is helpful, but only if you already know what to do. A complete guide would be better and I think it would only be a few sentences to explain the details.Leave a comment:
-
Leave a comment:
-
item thanks for your reply i already tried your solution before posting here and it didn't work because that solution would only work for enum and in my case i am using multi-enum which treated differently, big thanks to yuri who helped me sort it out, there are two ways to achieve this see both code below:
Second way to achieve this below (both ways works) - second way allow to give more specific conditions e.g only accountType (Introducer):Code:<?php namespace Espo\Custom\Classes\Select\Account\PrimaryFilters; use Espo\Core\Select\Primary\Filter; use Espo\ORM\Query\SelectBuilder; use Espo\Core\Select\Where\ConverterFactory; use Espo\Entities\User; class PartnerClients implements Filter { private $converterFactory; private $user; public function __construct(ConverterFactory $converterFactory, User $user){ $this->converterFactory = $converterFactory; $this->user = $user; } public function apply(SelectBuilder $queryBuilder): void { $converter = $this->converterFactory->create('Account', $this->user); $whereClause = $converter->convert( $queryBuilder, (new \Espo\Core\Select\Where\ItemBuilder) ->setAttribute('accountType') ->setType('arrayAllOf') ->setValue(['Client', 'Introducer']) ->build() ); $queryBuilder->where($whereClause); } }
I hope this help someone.Code:<?php namespace Espo\Custom\Classes\Select\Account\PrimaryFilters; use Espo\Core\Select\Primary\Filter; use Espo\ORM\Query\SelectBuilder; use Espo\ORM\Query\Part\Condition as Cond; class OnlyActiveIntroducers implements Filter { public function apply(SelectBuilder $queryBuilder): void { $introducer = SelectBuilder::create() ->from('ArrayValue') ->select('entityId') ->where([ 'value' => 'Introducer', 'attribute' => 'accountType', 'entityType' => 'Account', 'deleted' => false, ]) ->build(); $notClient = SelectBuilder::create() ->from('ArrayValue') ->select('entityId') ->where([ 'value' => 'Client', 'attribute' => 'accountType', 'entityType' => 'Account', 'deleted' => false, ]) ->build(); $notAccountant = SelectBuilder::create() ->from('ArrayValue') ->select('entityId') ->where([ 'value' => 'Accountant', 'attribute' => 'accountType', 'entityType' => 'Account', 'deleted' => false, ]) ->build(); $queryBuilder ->where( Cond::and( Cond::in(Cond::column('id'), $introducer), Cond::notIn(Cond::column('id'), $notClient), Cond::notIn(Cond::column('id'), $notAccountant), Cond::in(Cond::column('state'), ['Active']), ) ); } }
Thank you guys for your support, i love this community.Leave a comment:
-
Hi,
your sample is for enum field, not for multi-enum
see on GitHub closed issue where Yuri have post solution
Leave a comment:
-
Custom primary filter for multi-enum
I have created a custom primary filter but it is not working, i don't know how to get values for a multi-enum field, below code doesn't work. anyone knows how to get value for multi-enum field using the SelectBuilder :
the companyType is a multi-enum field so i am trying get the companyType values both Client and Introducer.Code:<?php namespace Espo\Custom\Classes\Select\Account\PrimaryFilters; use Espo\Core\Select\Primary\Filter; use Espo\ORM\Query\SelectBuilder; class Clients implements Filter { public function apply(SelectBuilder $queryBuilder): void { $queryBuilder->where([ 'companyType' => ['Client', 'Introducer'], ]); } }
ThanksTags: None

Leave a comment: