Announcement

Collapse
No announcement yet.

CRITICAL: (42S22) SQLSTATE[42S22]: Column not found: 1054 Unknown column

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CRITICAL: (42S22) SQLSTATE[42S22]: Column not found: 1054 Unknown column

    ​Hi,

    I've created a primary filter in Account entity and it works OK, but I've tried to do the same in a custom entity (CProject) in the same way but It shows an error:

    [2024-07-08 10:55:19] CRITICAL: (42S22) SQLSTATE[42S22]: Column not found: 1054 Unknown column 'c_project.status' in 'where clause' :: GET /CProject :: /var/www/html/crm/application/Espo/ORM/Executor/DefaultSqlExecutor.php(77)


    I'm sure the table c_project and the column status exist in the DB.

    Hard rebuild and clean cache already done.

    EspoCRM version: 8.3.4

    These are the steps I've followed:


    1.- I've created the files Active.php and Inactive.php in /var/www/html/crm/custom/Espo/Custom/Select/CProject/PrimaryFilters

    Code:
    <?php
    namespace Espo\Custom\Select\CProject\PrimaryFilters;
    
    use Espo\Core\Select\Primary\Filter;
    use Espo\ORM\Query\SelectBuilder;
    use Espo\ORM\Query\Part\Condition as Cond;
    
    class Active implements Filter {
    public function apply(SelectBuilder $queryBuilder): void {
    $queryBuilder->where(
    ['c_project.status' => 'Active']
    );
    }
    }
    Code:
    <?php
    namespace Espo\Custom\Select\CProject\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(
    ['c_project.status' => 'Inactive']
    );
    }
    }

    2.- I've created the file CProject.json in /var/www/html/crm/custom/Espo/Custom/Resources/metadata/selectDefs

    Code:
    {
    "primaryFilterClassNameMap": {
    "Activos": "Espo\\Custom\\Select\\CProject\\PrimaryFilters\\Active",
    "Inactivos": "Espo\\Custom\\Select\\CProject\\PrimaryFilters\\Inactive"
    }
    }

    3.- I've modified the file CProject.json in /var/www/html/crm/custom/Espo/Custom/Resources/metadata/clientDefs adding the filters name.

    Code:
    "filterList": [
    {
    "name": "Activos"
    },
    {
    "name": "Inactivos"
    }
    ],​​
    The filters are shown in the search bar of the entity but appears an Error 500 and the filters don't work.

    ​​ Click image for larger version  Name:	image.png Views:	0 Size:	33.3 KB ID:	108211
    ​​


    Thank you for your help
    Last edited by jtubee; 07-08-2024, 12:22 PM.

  • #2
    Hi,

    PHP Code:

            $queryBuilder
    ->where([
                
    'status' => 'Inactive',
            ]);
    ​ 

    Comment


    • #3
      It works!

      Thank you very much!

      Comment

      Working...
      X