How to Use Dashlet Filters with Custom Fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Carolus
    Junior Member
    • May 2025
    • 2

    #1

    How to Use Dashlet Filters with Custom Fields

    I’m looking for a way to expand the "Primary Filter" options in EspoCRM for the Contact entity.

    Current Setup:
    • Custom Field:
      • Name: Privatcontact
      • Type: Checklist (with "Yes option)
    • Primary Filter Limitations:
      Currently, I only see two default options:
      • All
      • Portal Users
    Goal:
    I want to create a dashlet on the homepage that displays only contacts marked as "Privatcontact = Yes".

    Questions:
    1. Is there a way to add custom filters (like Privatcontact = Yes) to the primary filter dropdown?
    2. If not, what’s the best workaround to achieve this (e.g., via Advanced Pack, workflows, or a custom view)
    I’d appreciate any guidance or steps to resolve this.
  • item
    Active Community Member
    • Mar 2017
    • 1521

    #2
    Hi,
    i know, we can do filter with Advanced Pack but forget.

    via code :




    custom/Espo/Custom/Classes/Select/Account/PrimaryFilters/Actual.php
    PHP Code:

    namespace Espo\Custom\Classes\Select\Account\PrimaryFilters;

    use 
    Espo\Core\Select\Primary\Filter;
    use 
    Espo\ORM\Query\SelectBuilder;

    class 
    Actual implements Filter
    {
        public function 
    __construct()
        {}

        public function 
    apply(SelectBuilder $queryBuilder): void
        
    {
            
    $queryBuilder->where([
                
    'status' => ['New''Active'],
            ]);
        }

    custom/Espo/Custom/Resources/metadata/selectDefs/Account.json

    PHP Code:

    {
        
    "primaryFilterClassNameMap": {
            
    "Actual""Espo\\Custom\\Classes\\Select\\Account\\PrimaryFilters\\Actual"
        
    }

    custom/Espo/Custom/Resources/metadata/clientDefs/Account.json

    PHP Code:
    {
        
    "filterList": [
            {
                
    "name""Actual",
                
    "style""warning"
            
    }
        ]
    }
    ​ 
    clearCache, rebuild

    I hope, i have not forget other needed code..
    Last edited by item; Today, 12:44 PM.
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • Carolus
      Junior Member
      • May 2025
      • 2

      #3
      Thanks for your responce.
      I cant find this stucture on the hosting
      until the map /custom/Espo/Custom is there, in this map I see only map Controllers and Resources.
      I don't have Advanced Packed, thats possible the reason thats the structure is different.

      If there is an another solution I appreciate that.

      Comment


      • item
        item commented
        Editing a comment
        Hi,
        create the directory.. follow the path as my sample, change Account to Contact .. and the filter 'status' => ['New', 'Active'], to yours privatcontact => 'Yes' something so. see UpperCase LowerCase too
    Working...