How to disable back end field validation to avoid the "Field Validation" error

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • shalmaxb
    replied
    You can set the error handling to DEBUG in the file data->config-internal.php.
    Then you will get a more thorough error file.
    Perhaps also this thread helps: https://forum.espocrm.com/forum/deve...help-with-hook
    and perhaps this in Documentation: https://docs.espocrm.com/development/hooks/

    Maybe outdated coding of the hook.

    Leave a comment:


  • arthurmaciel
    replied
    shalmaxb, I wasn't using any formulas for theses date field. But the date string was coming from an external application. My installation of Mariadb, despite all it says about accepted date formats, really only accepts dates as you've presented: YYYY-MM-DD (not YYYY/MM/DD). I have changed the external application date format and now it works. Thanks!

    But in my espo log now I have the following error, related to a hook. I appreciate any help!

    Code:
    [2025-12-23 15:06:01] ERROR: Slim Application Error Type: Error Code: 0 Message: Call to undefined method Espo\Custom\Hooks\Paciente\AtualizaCID::getEntityManager() File:
    /var/www/mydom.org/espocrm/custom/Espo/Custom/Hooks/Paciente/AtualizaCID.php Line: 11 Trace: #0
    /var/www/mydom.org/espocrm/application/Espo/Core/Hook/GeneralInvoker.php(186): Espo\Custom\Hooks\Paciente\AtualizaCID->afterSave() #1
    /var/www/mydom.org/espocrm/application/Espo/Core/HookManager.php(118): Espo\Core\Hook\GeneralInvoker->invoke() #2
    /var/www/mydom.org/espocrm/application/Espo/Core/Repositories/Database.php(344): Espo\Core\HookManager->process() #3
    /var/www/mydom.org/espocrm/application/Espo/ORM/Repository/RDBRepository.php(172): Espo\Core\Repositories\Database->afterSave() #4
    /var/www/mydom.org/espocrm/application/Espo/Core/Repositories/Database.php(144): Espo\ORM\Repository\RDBRepository->save() #5
    /var/www/mydom.org/espocrm/application/Espo/ORM/EntityManager.php(253): Espo\Core\Repositories\Database->save() #6
    /var/www/mydom.org/espocrm/application/Espo/Core/Record/Service.php(801): Espo\ORM\EntityManager->saveEntity() #7
    /var/www/mydom.org/espocrm/application/Espo/Core/Controllers/RecordBase.php(230): Espo\Core\Record\Service->update() #8
    /var/www/mydom.org/espocrm/application/Espo/Core/Api/ControllerActionProcessor.php(87): Espo\Core\Controllers\RecordBase->putActionUpdate() #9
    /var/www/mydom.org/espocrm/application/Espo/Core/Api/ControllerActionHandler.php(65): Espo\Core\Api\ControllerActionProcessor->process() #10
    /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(73): Espo\Core\Api\ControllerActionHandler->handle() #11
    /var/www/mydom.org/espocrm/application/Espo/Core/Api/RouteProcessor.php(221): Slim\MiddlewareDispatcher->handle() #12
    /var/www/mydom.org/espocrm/application/Espo/Core/Api/RouteProcessor.php(148): Espo\Core\Api\RouteProcessor->processControllerAction() #13 /var/www/mydom.org/espocrm/application/Espo/Core/Api/RouteProcessor.php(126): Espo\Core\Api\RouteProcessor->processAfterAuth() #14
    /var/www/mydom.org/espocrm/application/Espo/Core/Api/RouteProcessor.php(78): Espo\Core\Api\RouteProcessor->processInternal() #15
    /var/www/mydom.org/espocrm/application/Espo/Core/Api/Starter.php(126): Espo\Core\Api\RouteProcessor->process() #16
    /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(38): Espo\Core\Api\Starter->{closure:Espo\Core\Api\Starter::addRoute():117} () #17
    /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/Routing/Route.php(363): Slim\Handlers\Strategies\RequestResponse->__invoke() #18
    /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(73): Slim\Routing\Route->handle() #19
    /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(73): Slim\MiddlewareDispatcher->handle() #20
    /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/Routing/Route.php(321): Slim\MiddlewareDispatcher->handle() #21
    /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/Routing/RouteRunner.php(74): Slim\Routing\Route->run() [NODE="22"]Unminify assets or how to recreate t...o.min.js file?[/NODE]
    /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(45): Slim\Routing\RouteRunner->handle() [NODE="23"]Unminify assets or how to recreate t...o.min.js file?[/NODE] /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(129): Slim\Middleware\RoutingMiddleware->process() #24
    /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(77): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() [NODE="25"]Unminify assets or how to recreate t...o.min.js file?[/NODE]
    /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(129): Slim\Middleware\ErrorMiddleware->process() [NODE="26"]how to upgrade ?[/NODE]
    /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/MiddlewareDispatcher.php(73): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() [NODE="27"]how to upgrade ?[/NODE]
    /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/App.php(209): Slim\MiddlewareDispatcher->handle() #28 /var/www/mydom.org/espocrm/vendor/slim/slim/Slim/App.php(193): Slim\App->handle() #29 /var/www/mydom.org/espocrm/application/Espo/Core/Api/Starter.php(84): Slim\App->run() #30
    /var/www/mydom.org/espocrm/application/Espo/Core/ApplicationRunners/Api.php(45): Espo\Core\Api\Starter->start() #31
    /var/www/mydom.org/espocrm/application/Espo/Core/Application/RunnerRunner.php(84): Espo\Core\ApplicationRunners\Api->run() [NODE="32"]Unminify assets or how to recreate t...o.min.js file?[/NODE]
    /var/www/mydom.org/espocrm/application/Espo/Core/Application.php(86): Espo\Core\Application\RunnerRunner->run() [NODE="33"]Quotes[/NODE]
    /var/www/mydom.org/espocrm/public/api/v1/index.php(35): Espo\Core\Application->run() [NODE="34"]Quotes[/NODE] {main} Tips: [B]To display error details in HTTP response set "displayErrorDetails" to true in the ErrorHandler constructor.[/B]
    Does anyone know where to set the "displayErrorDetails" to true?

    Best

    PS: It is worthy mentioning that all the hooks and the date fields worked like a charm before the Espo upgrade. It is a pitty that no warning notice of changes was shown when upgrading. I definitely wouldn't have upgraded if I knew it would take so many hours to only partially fix it. Espo is a great piece of software, but the upgrade process could show a changelog to make sure the user understands the possible impacts of changing versions.

    Leave a comment:


  • shalmaxb
    replied
    I guess, it could be because of the internal date format in espocrm, which is YYYY-MM-DD. Maybe you use any formula between your admissao and nascimentoData. If you need another date format in the field different from the internal format, you must adapt your format in that formula (date\format). This will keep the internal format, but display your desired format.




    Leave a comment:


  • arthurmaciel
    replied
    Originally posted by shalmaxb
    could you please post the log file (to find in data->logs)
    Hi, shalmaxb!

    I have already posted:

    Code:
    DEBUG: API (400) validationFailure; POST /Paciente; Input data: {"assignedUsersIds":["xxxxx"],[B]"admissao":"21/12/2025"[/B],"firstName":"xxxxx","lastName":"xxxxx","phoneNumb er":"xxxxx","emailAddress":"xxxx",[B]"nascimentoData":"12/10/1987"[/B]}; Route pattern: /{controller}; Route params: Array ( [controller] => Paciente [action] => create )
    WARNING: (400) [B]Field validation failure; entityType: Paciente, field: admissao, type: valid[/B]. :: POST /Paciente
    I've omitted some info, because it is personal data (marked as "xxxxxx" above).

    Thanks!

    Leave a comment:


  • shalmaxb
    replied
    could you please post the log file (to find in data->logs)

    Leave a comment:


  • arthurmaciel
    replied
    Hi!

    I've updated EspoCRM from 7.4 to 9.2.5 using 'php command.php upgrade' and all went fine during the process.

    But now when I try to create a custom entity record I get the Field Validation Error message. As this entity creation is central to my CRM, my application is completely broken.

    When it is not the field "admissao" (when I delete it for example), the culprit becomes the field 'nascimentoData', both dates set up in Preferences as "DD/MM/YYYY", with the following metadata on espocrm/custom/Espo/Custom/Resources/metadata/entityDefs/Paciente.json:

    Code:
    DEBUG: API (400) validationFailure; POST /Paciente; Input data: {"assignedUsersIds":["xxxxx"],[B]"admissao":"21/12/2025"[/B],"firstName":"xxxxx","lastName":"xxxxx","phoneNumber":"xxxxx","emailAddress":"xxxx",[B]"nascimentoData":"12/10/1987"[/B]}; Route pattern: /{controller}; Route params: Array ( [controller] => Paciente [action] => create )
    WARNING: (400) [B]Field validation failure; entityType: Paciente, field: admissao, type: valid[/B]. :: POST /Paciente
    ​
    Code:
    "admissao": {
    "notNull": false,
    "type": "date",
    "default": "javascript: return this.dateTime.getToday();",
    "isCustom": true,
    "validationList": [],
    "mandatoryValidationList": []
    
    },
    "nascimentoData": {
    "notNull": false,
    "type": "date",
    "isCustom": true,
    "validationList": [],
    "mandatoryValidationList": []
    }​


    Could anyone help me please? If it doesn't work, I'll have to downgrade Espo, but also my PHP version and it will be a hassle.

    Best,
    Arthur



    Maybe other relevant info:

    PHP 8.4.13 (cli) (built: Dec 4 2025 02:46:17) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.4.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.13, Copyright (c), by Zend Technologies​
    Welcome to the MariaDB monitor. Commands end with ; or \g.
    Your MariaDB connection id is 795532
    Server version: 11.8.3-MariaDB FreeBSD Ports
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

    Permissions are all correctly set.


    ------------------------------

    Originally posted by telecastg
    Sometimes, for whatever reason, it is preferred to bypass Espo's built in field validation rules to avoid triggering the "Field Validation Error" message and interrupting the back end program flow.

    Fortunately, this is now possible using metadata settings, so it is not necessary to do any coding to accomplish this.

    Simply add these two parameters in your custom entity entityDefs json file under the field for which you want to bypass all validations:

    Code:
    "validationList": [],
    "mandatoryValidationList": []​

    For participants that do not mind writing code, the documentation https://docs.espocrm.com/development...validationlist has information on how to define and invoke custom back end validations in case this is the preferred solution.

    Leave a comment:


  • item
    replied
    Hi Telecastg,

    found-it
    As reminder is a entity.. so this work in entityDefs meeting.json
    I have leave out-of-box validatorMaxCount, i will copy-past the other valid in custom folder.

    PHP Code:
    {
        
    "fields": {
            
    "reminders": {
                
    "validatorClassNameList": [
                    
    "Espo\\Modules\\Crm\\Classes\\FieldValidators\\Event\\Reminders\\MaxCount"
                
    ]
            },
    ​ 
    And in entityDefs reminder.jon :

    PHP Code:
    {
        
    "fields": {
            
    "type": {
                
    "options": [
                    
    "__APPEND__",
                    
    "Sms"
                
    ]
            }
        }
    }
    ​ 
    Regards

    Leave a comment:


  • telecastg
    commented on 's reply
    Hello @item

    Easiest solution is to write this:

    {
    "fields": {
    "type": {
    "type": "enum",
    "options": [
    "__APPEND__",
    "Sms"
    ],
    "validationList": [],
    "mandatoryValidationList": []
    }
    }
    }

    The above will tell the system to ignore the hard coded validation rules.

  • item
    replied
    Hi telecastg

    i have a question for you :
    i have create a custom entityDefs reminder.json
    PHP Code:
    {
        
    "fields": {
            
    "type": {
              
    "type""enum",
                
    "options": [
                    
    "__APPEND__",
                    
    "Sms"
                
    ]
            }
        }
    }
    ​ 
    I see Sms in reminder->type... but validation issue.
    Error 400: Bad request
    Backend validation failure.

    Field: reminders
    Validation: valid


    I have seach but it's hard code TYPE_EMAIL, TYPE_EMAIL on field Validator.
    Where do i have put for disable validator and create my own field validator who are just a copy past out-of-box validator and add 'Sms'

    Thanks

    Leave a comment:


  • abisbe
    replied
    I had the same issue Upgrading to 7.3.4, this solved my issue, as we probably had some misadjustment from the people that developed the site we use for the payments, but the update really meant that for 3 days until we noticed, no payments were being registered into the system, because the policy of field validation changed.

    I had the same issue too when copying the solution, it added an extra character, but thanks to that you posted the solution here it was solved quickly too.

    Thank you all!

    Leave a comment:


  • shalmaxb
    replied
    item and telecastg

    Great! That did it. The shown characters, which are not visible in the editor I use (Notepad++) is the so called "zero width space" (I think the 0x200b ist the HEX code for that character). In another discussion I found the reason: This character is inserted by Google Chrome (don`t know if in other browsers too) and you see them as soon as you open the browser tools pointing to the code inserted in the first thread, see photo.
    As soon as I typed the code instead of copying, it worked.
    Thank you for your efforts and hints!

    Leave a comment:


  • item
    replied
    i have just copy past .. in "sublime text" editor :
    i don't know what's is "​​​<0x200b>" .. it's maybe invaders ..

    Leave a comment:


  • telecastg
    commented on 's reply
    I I see the same red dot in shalmaxb code when I run it through https://jsonlint.com/ as item suggested, and it throws an error, but if I simply remove the red dot it works fine.

    I suggest trying that and then copy and paste the "clean" code into your json file

  • item
    commented on 's reply
    Hello @telecastg
    Yes red point

    JSONLint is the free online validator, json formatter, and json beautifier tool for JSON, a lightweight data-interchange format. You can format json, validate json, with a quick and easy copy+paste.


    I have just add 2 braket and copy/past the code between braket

    Results

    Error: Parse error on line 8:
    ...yValidationList": []​ }}
    -----------------------^
    Expecting 'EOF', '}', ',', ']', got 'undefined'

    My experiment, each time you have error json and not see nothing anything, the json have special encoding bad caractère

    You then do not copy/past but write manually the 2 lines
    Last edited by item; 03-12-2023, 10:38 AM.

  • telecastg
    commented on 's reply
    Is that the red dot item ? How did you find it ?

    I checked shalmaxb posted code with Notepad++ and could not reproduce the error

    I also checked on my installation and I have an entityDefs file like this, working without any problems

    "startingDate": {
    "type": "datetime",
    "validationList": [],
    "mandatoryValidationList": []
    },
    "endingDate": {
    "type": "datetime",
    "validationList": [],
    "mandatoryValidationList": []
    },
    "firstExecutionDate": {
    "type": "datetime",
    "validationList": [],
    "mandatoryValidationList": []
    },
    Last edited by telecastg; 03-12-2023, 05:11 AM.
Working...