Integer Field Length

Kumar38
Kilo Sage

Created a few Integer Fields, Assigned them a  Max Length of 4 . But It still accepts more than 4 . How do I fix this ?

Thanks

 

1 ACCEPTED SOLUTION

This thread could be useful. You can't restrict it based on the length. You will have to add your own validations

 

https://community.servicenow.com/community?id=community_question&sys_id=db660fe1db1cdbc01dcaf3231f96...


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

4 REPLIES 4

SanjivMeher
Kilo Patron
Kilo Patron

You can add a Business Rule to show error message if the field value >9999


Please mark this response as correct or helpful if it assisted you with your question.

Just Curious why Setting MAX length of 4 while creating Variable is not working for Field type -Integer ? Is that a Known Issue ?

 

find_real_file.png

This thread could be useful. You can't restrict it based on the length. You will have to add your own validations

 

https://community.servicenow.com/community?id=community_question&sys_id=db660fe1db1cdbc01dcaf3231f96...


Please mark this response as correct or helpful if it assisted you with your question.

Nithish1
Tera Guru

Hi Rali,

Here's an onchange script that returns an alert and clears out the value of the field if it's not 4 digits.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

  if (isLoading || newValue == '') {

      return;

  }

  if (newValue.toString().length != 4) {

      alert("Please enter a 4 digit number");

      g_form.setValue('fieldname', '');

  }

}

 

Thanks,

Nithish

P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.