Hello! I have been busy solving my own primary filters a few days ago. The existing posts were only partly of help, as the basic structure (Select Manager to Select Builder) has been changed in version 7.
Attached is a little help. I hope it helps someone.
My initial situation: The entity contact has got a new enum field "ownState". Possible entries are "activce, feedback, inactive". The default value is "active". I wanted a filter like for the leads "actual" and "inactive".
Folders or files may need to be created.
/custom/Espo/Custom/Select/Contact/PrimaryFilters/Actual.php
/custom/Espo/Custom/Select/Contact/PrimaryFilters/Inactive.php
/custom/Espo/Custom/Ressources/metadata/selectDefs/Contact.json
/custom/Espo/Custom/Ressources/metadata/clientDefs/Contact.json
Add the following value
/custom/Espo/Custom/Ressources/i18n/de_DE/Contact.json
Please select the appropriate language. In my case German. Add the following value
Finally
/application/Espo/ORM/Query/Part/
Attached is a little help. I hope it helps someone.
My initial situation: The entity contact has got a new enum field "ownState". Possible entries are "activce, feedback, inactive". The default value is "active". I wanted a filter like for the leads "actual" and "inactive".
Folders or files may need to be created.
/custom/Espo/Custom/Select/Contact/PrimaryFilters/Actual.php
PHP Code:
<?php
namespace Espo\Custom\Select\Contact\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
use Espo\ORM\Query\SelectBuilder;
use Espo\ORM\Query\Part\Condition as Cond;
class Actual implements Filter
{
public function apply(SelectBuilder $queryBuilder): void
{
$queryBuilder->where(
Cond::in(
Cond::column('ownState'),
['active','feedback']
)
);
}
}
/custom/Espo/Custom/Select/Contact/PrimaryFilters/Inactive.php
PHP Code:
<?php
namespace Espo\Custom\Select\Contact\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
use Espo\ORM\Query\SelectBuilder;
use Espo\ORM\Query\Part\Condition as Cond;
class Inactive implements Filter
{
public function apply(SelectBuilder $queryBuilder): void
{
$queryBuilder->where(
Cond::in(
Cond::column('ownState'),
['inactive']
)
);
}
}
/custom/Espo/Custom/Ressources/metadata/selectDefs/Contact.json
Code:
{ "primaryFilterClassNameMap": { "actual": "Espo\\Custom\\Select\\Contact\\PrimaryFilters\\Actual", "inactive": "Espo\\Custom\\Select\\Contact\\PrimaryFilters\\Inactive" } }
/custom/Espo/Custom/Ressources/metadata/clientDefs/Contact.json
Add the following value
Code:
"filterList":[ { "name":"actual" }, { "name":"inactive" } ]
/custom/Espo/Custom/Ressources/i18n/de_DE/Contact.json
Please select the appropriate language. In my case German. Add the following value
Code:
"presetFilters": { "actual": "Aktuell", "inactive": "Archiv" }
Finally
- Administation: Clear Cache
- Reload Site in Browser
/application/Espo/ORM/Query/Part/
Comment