We have a field "Active" in our customer data (account entity). Is there a way to display only the active entries in List view by default?
Thanks for your help
Thanks for your help
<?php
namespace Espo\Custom\Classes\Select\Account\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
use Espo\ORM\Query\SelectBuilder;
class Active implements Filter
{
public function apply(SelectBuilder $queryBuilder): void
{
$queryBuilder->where([
'isActive' => true,
]);
}
}
{
"primaryFilterClassNameMap": {
"active": "Espo\\Custom\\Classes\\Select\\Account\\PrimaryFilters\\Active"
}
}
{
"filterList": [
"__APPEND__",
"active",
{
"name": "active",
"style": "success"
}
],
"defaultFilterData": {
"primary": "active"
}
}
"relationshipPanels": {
"contacts": {
"selectHandler": "handlers/select-related/same-account-many" // This is the line you need to add ad the end of your contacts
}
}
"selectHandler": "handlers/select-related/same-account-many"
"contacts": {
"selectHandler": "custom:handlers/select-related/same-dealer-many"
},
define('custom:handlers/select-related/same-dealer-many', ['handlers/select-related'], Dep => {
return class extends Dep {
/**
* @param {module:model.Class} model
* @return {Promise<module:handlers/select-related~filters>}
*/
getFilters(model) {
let advanced = {};
let dealerId = null;
let dealerName = null;
if (model.get('dealerId')) {
dealerId = model.get('dealerId');
dealerName = model.get('dealerName');
}
if (!dealerId && model.get('parentType') === 'Dealer' && model.get('parentId')) {
dealerId = model.get('parentId');
dealerName = model.get('parentName');
}
if (dealerId) {
let nameHash = {};
nameHash[dealerId] = dealerName;
advanced.dealers = {
field: 'dealers',
type: 'linkedWith',
value: [dealerId],
data: {nameHash: nameHash},
};
}
return Promise.resolve({
advanced: advanced,
});
}
}
});
Comment