We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Max length for an Int field not working?

Mitch Moses
Giga Expert

find_real_file.png

 

find_real_file.png

1 ACCEPTED SOLUTION

I think its a bug in SN. If you have HI account, post a request there and they should help you.

Regarding the fix, you can use client script.

Write a onchange client script on your Bridge meeting field like below

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
	if(newValue.length>1) {
		g_form.showErrorBox("u_bridge_meeting","You cannot enter more than 1 digit",true);
	}
}

Mark the comment as a correct answer and also helpful once worked.

View solution in original post

9 REPLIES 9

asifnoor
Kilo Patron

Hi Mitch,

The Max Length works only for string data type. For others it is ignored, hence you are able to input more numbers.

Ref: https://old.wiki/index.php/Creating_a_Custom_Table (Search for Max Length in this and you will get more info)

Mark the comment as a correct answer and also helpful if it answers your question.

Wait why is this a thing? and how should I come up with a solution for this?

I think its a bug in SN. If you have HI account, post a request there and they should help you.

Regarding the fix, you can use client script.

Write a onchange client script on your Bridge meeting field like below

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
	if(newValue.length>1) {
		g_form.showErrorBox("u_bridge_meeting","You cannot enter more than 1 digit",true);
	}
}

Mark the comment as a correct answer and also helpful once worked.

This will not work, you have to convert it to a string to check the length.