Announcement

Collapse
No announcement yet.

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

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

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

    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.

  • #2
    thanks for sharing.

    Comment


    • telecastg
      telecastg commented
      Editing a comment
      You're very welcome rabii

  • #3
    telecastg
    I tried to use this code for one field, but I get a json error (wrong code). It might be because of the [ ]. Has there to be any value? Or just leaving the brackets?
    Thank you in advance.

    Comment


    • shalmaxb
      shalmaxb commented
      Editing a comment
      Thank you, then that is, why it does not work here, my client uses 7.3.2. Will recommend to him to update and then try again.

    • telecastg
      telecastg commented
      Editing a comment
      If it doesn't work, try checking the entitDefs custom script with your development platform/ editor to see if it detects any json structure errors. I use Eclipse from Apache and it will highlight json structure errors.


      Another option (just for you friend, because you always help everyone), post the code from 'custom/Espo/Custom/Resources/metadata/entityDefs/Quote.json' and I will take a look too.

    • telecastg
      telecastg commented
      Editing a comment
      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

  • #4
    Hi,
    thank you for your offer telecastg.
    Here is the field, that needs to bypass the validation:

    Code:
    "shippingCost": {
    "tooltip": true,
    "default": 10,
    "onlyDefaultCurrency": false,
    "conversionDisabled": false,
    "validationList": [],
    "mandatoryValidationList": []​
    },​
    but still on rebuild I get a json code error, which is not there, when I rebuild without the two lines. Version espoCRM is now 7.3.4

    Comment


    • #5
      special caractere at the end !

      Comment


      • telecastg
        telecastg commented
        Editing a comment
        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, 04:11 AM.

      • item
        item commented
        Editing a comment
        Hello @telecastg
        Yes red point

        JSONLint is the free online validator and json formatter 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, 09:38 AM.

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

      Comment


      • #7
        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!

        Comment

        Working...
        X