a!integerField() length validation issue

I am facing weird issue in a!integerField. When i enter 11 digit or more than that in integerField it throws validation message as 

which is understandable as it converts number to exponential which appian does not support.

But when i enter 20 digit number it throws validation message as


Why it shows value is too small?
Anyone faces same issue?

Thanks,

Shubham

  Discussion posts and replies are publicly visible

  • Hi Shubham Aware,

    Yes, previously i have faced same issue in my application. a!integerField() component accepts only 10 digits, it won't accept more than 10 digits, instead of using integerField() as per my knowledge it's better to use textField() component, it will accept more than 10 digits.
  • Hi,
    When working with large numbers you will most likely find different behaviour between fields (text, integer, floatingpoint), so a workaround is to convert the value to text and work with that.

    You could also try convert the value to decimal and use the dollar() function.

  • You can use textfield, and you can provide custom validations when user enters other than numbers. If your SQA doesnot raise an issue like above you and you are pretty sure that Business will not enter more than 10 digits in the integer field you can retain that as this is the default behaviour of Integer field.

    I wonder when i test for 20 digits in 18.2 and for me it is no giving the other error mentioned by you.
  • Hi Shubham,

    You can use text field, so that it allows you to enter more than 10 digits.And you can also show an integer as currency using text which is given below.
    Example: a!textField(
    label: "Amount",
    value: dollar(12345),
    readOnly: true
    )

    Thanks,
    ravalik
  • Hi ,

    I have also faced same issue, Appian converts value in integer field to the exponential.
    So what you can do is use text fields for numbers and give custom validation for its length.
  • Hi Shubham Aware,
    I was also facing the same issue and to overcome with this we used a!textfield instead of a!intergerfield.
    but to restrict the user to enter only numeric values in the text field we created one more expression that removes alphabet and special characters from the value.
    ##ABC_Utils_RemoveAlphabetsAndSpecialCharacter
    concat(
    tointeger(
    apply(
    charat(
    ri!String,
    _
    ),
    enumerate(
    lenb(
    ri!String
    )
    ) + 1
    )
    )
    )
    Replace your integer field with this code
    _____________________________________________________________________________________________________
    a!textField(
    label: "Amount",
    value: rule!ABC_Utils_RemoveAlphabetsAndSpecialCharacter(
    String: ri!String
    ),
    saveInto: a!save(
    ri!String,
    rule!ABC_Utils_RemoveAlphabetsAndSpecialCharacter(
    String: save!value
    )
    )
    )
  • Hi Shubam,

    While other practitioners have explained how to get around this problem, I will explain why it happened.

     

    Why do you see the number is too large/number is too small:

    1. Because Appian uses Java datatypes.

    2. An Integer in Java datatype is 32 bits. 1 bit is reserved for the sign. So only 31 bits are avaialble to be used. All computers use the two's complement representation.

    3. Hence maximum magnitude of a number is (2^31)-1 - which is equal to  2,147,483,647 

    4. If you try the above number in a!integerField , you will get "number is too large"

    5. But, if you try the number which is just one less than the above number i.e  2,147,483,646, no error will come.

    6. So you can see , the max number is limited by the size of the CPU registers.

    7. Now if you have a number larger than the max number,  the CPU will get an overflow exception. In this case, it will wrap it in negative numbers. So a number like  2,147,483,649 will be considered as -2 ( 2,147,483,647 - 2,147,483,649   )

    8. That is why technically we can say - max allowed number (int) by Appian is  2,147,483,646. (See it has 10 digits). Note that 10 digit numbers greater than this number would also get validation error.

    9. An underflow can occur when CPU encounters a very very negative number (big magnitude but negative sign).

    10. In point 7, just consider that the user has entered a very very big number in the SAIL field. Twenty 1s as mentioned by you.. then the overflow exception will happen in CPU and CPU will actually think of it a negative number - but if the number was too big, the result will be considered a very big negative number ( 2,147,483,647  - 11111111111111111111)

    11. That is why you got "number is too small" error.

    12. By the way it seems Appian has fixed the latter part.

     

    I am not sure what Appian version you tested on.

    But, in Appian version I have Appian is behaving as per user expectation. For a very very large number (like twenty 1s) the error is still "value is too large".

    Now note that from a CPU perspective: it is actually overflow and a very small value (large magnitude but negative sign), but for end user it is  a very large number.

    So we have a interesting situation here: CPU is actually showing the correct error when it says number is too small. It is all because of the way numbers are stored in registers.

    But for the end user it is not the same case. The end user and the CPU would be on same page only if the regsiters had infinite bits :-)

    It seems Appian has fixed this -  so that for all numbers greater than  2,147,483,646 - you will simply get number is too large error. 

    This is observed in Appian env that I have.

     

    Hope this clarified the "why" part.

     

    Also try the following SAIL code:

    It will show "infinity" symbol in the Integer field.

    But . you can enter the same number by hand - and it will give the validation error that  you got.

     

    load(

    local!num1: 2147483647,


    a!integerField(
    label: "Integer",
    labelPosition: "ABOVE",
    saveInto: local!num1,
    value: local!num1,
    refreshAfter: "UNFOCUS",
    validations: {}
    )

    )

  • one of the weird features that appian documentation doesn't explain. Integer accepts only 10 digits.
  • Numeric fields have a size limit that will not allow large numbers to be entered and saved. They are sometimes turned into infinity as well. Instead you can use a text field and in the save use tointeger() if you need it to be an integer later.