Integer field has a maximum limit of 10 digits?

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • fberbert
    replied
    Originally posted by victor
    In your particular case, it is better to use a different field type (for example, Varchar) or you can try the following:

    1. In your_instance_name/custom/Espo/Custom/Resources/metadata/entityDefs/Your_entity.json find your field and under the line
    Code:
    "type": "int",
    add
    Code:
    "dbType": "bigint",
    Thanks for sharing, your tip saved my day! ✅

    Leave a comment:


  • shalmaxb
    replied
    The Regex belongs in the field itself, see screenshot Click image for larger version

Name:	regex.jpg
Views:	185
Size:	23.4 KB
ID:	107176

    Leave a comment:


  • mansi.kakkar
    replied
    shalmaxb Ok, I used this formula in the varchar field's condition. But, its showing me invalid if I try to add numbers. Did I wrote something wrote?
    PS. Its not required to have exactly 12 digits if its a varchar field, that was the issue with int field.

    Click image for larger version  Name:	image.png Views:	0 Size:	8.6 KB ID:	107172​​​
    Attached Files

    Leave a comment:


  • shalmaxb
    replied
    As already recommended in thread #2, change the field to BIGINT or VARCHAR. To limit the digits to 12 and only numbers, I guess regex would help. Here the AI solution (did not test it):

    To create a regular expression that limits a number to exactly 12 digits and allows only numeric characters, you can use the following pattern:

    ^[0-9]{12}$


    Here’s what each part of the regex means:
    • ^: The match must start at the beginning of the string.
    • [0-9]: Any character between ‘0’ and ‘9’.
    • {12}: Exactly 12 occurrences of the preceding character class.
    • $: The match must end at the end of the string.

    This pattern ensures that the input consists of exactly 12 numeric digits. If you need to allow leading zeros, you can modify it accordingly. ?

    For example, the regex would match:
    • 123456789012
    • 000000000001

    And it would not match:
    • 1234567890123 (13 digits)
    • abc123456789 (contains non-numeric characters)
    • 12345678a901 (contains non-numeric characters)

    Feel free to adjust the regex based on your specific requirements12. ?

    Leave a comment:


  • mansi.kakkar
    replied
    I will update soon, is there a way until then? There are two options:
    - Use an integer field but it should be able to store 12 digits, currently it stores upto 10 digits. Is there a way to fix that?
    - Use a varchar field. Can I put some condition to make this field invalid? (It should show invalid if contains alphabets or special characters)

    Leave a comment:


  • shalmaxb
    replied
    I recommend updating your instance. You will have to update one day, when espoCRM is already in ver 9 or even 10. And THAT will be difficult. From my experience, it is always preferable to update.

    Leave a comment:


  • mansi.kakkar
    replied
    shalmaxb Ah, ok. Is there any other way out for this problem?

    Leave a comment:


  • shalmaxb
    commented on 's reply
    API before save formula only works from version 7.5 and greater

  • mansi.kakkar
    replied
    shalmaxb victor I tried without the semicolon but it didn't work. Also, I just see the Before Save Custom Script in Formula (using version 7.0.9). Click image for larger version

Name:	image.png
Views:	595
Size:	5.0 KB
ID:	107014

    Leave a comment:


  • victor
    replied
    Possible reasons why it doesn't work for you:
    - Forum added an extra character at the end of the formula, which you then copied. I already edited it.
    - You didn't replace my Varchar field with your own.
    - You are confused Administration > Entity Manager > Your_entity_name > Formula > Before Save Custom Script and Administration > Entity Manager > Your_entity_name > Formula >API Before Save Script.​ For the last option, the formula should be used exactly in API Before Save Script​.

    Leave a comment:


  • shalmaxb
    commented on 's reply
    I think, the last semikolon should not be there.

  • mansi.kakkar
    replied
    victor Thanks for sharing this formula, but its not working. I have tried the exact formula, but even the alphabets are getting saved now.

    Leave a comment:


  • victor
    replied
    Originally posted by mansi.kakkar
    victor Thank you, this formula works. But, if a value other than 0-9 is put in cForumVarch, I would like it to through an error - Invalid. Can we modify this formula?
    shalmaxb gave a very good idea.

    1. Delete the formula suggested above https://forum.espocrm.com/forum/gene...942#post106942 from Administration > Entity Manager > Your_entity_name > Formula > Before Save Custom Script.
    2. Add the formula in Administration > Entity Manager > Your_entity_name > Formula >API Before Save Script.

    PHP Code:
    $cForumVarch string\match(cForumVarch'/^[0-9]*$/');

    if (
    cForumVarch != $cForumVarch) {
    recordService\throwBadRequest('field "Forum varch" accepts ONLY 0-9 digits');

    Last edited by victor; 06-06-2024, 06:53 AM.

    Leave a comment:


  • shalmaxb
    replied
    probably here: https://docs.espocrm.com/administrat...hrowbadrequest

    Leave a comment:


  • mansi.kakkar
    replied
    victor Thank you, this formula works. But, if a value other than 0-9 is put in cForumVarch, I would like it to through an error - Invalid. Can we modify this formula?

    Leave a comment:

Working...