Max length value of string field is not honoured

Nisar3
Giga Guru

In the sys_dictionary table, I've the following field:

Nisar3_0-1751455792196.png


But ServiceNow is allowing to store a value greater than 30 characters. For eg: It allowed to store a value of "Health and Safety - Customer responsibility" which is 43 characters long.

 

Is this expected?

1 ACCEPTED SOLUTION

SANDEEP DUTTA
Tera Patron
Tera Patron

Hi @Nisar3 ,

When you create a new sys_dictionary record to define a new string field, the max_length is mandatory. Despite the similarity of the name to HTML's maxlength attributes for input or textarea tags, this is not enforced as a limit in the client or server.

Max length is not enforced on the Now Platform

Fields in ServiceNow accept string inputs greater than the sys_dictionary max_length value. This is the expected behavior of the product.

When you create a string field in ServiceNow, the underlying column in the database is created with a default data type based in part on the specified max_length value:

  • Small (40) = varchar(40)
  • Medium (100) = varchar(100)
  • Large (1000) = mediumtext
  • Extra Large (4000) = mediumtext

Refer to below article for more details:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0685779

 

Thanks,
Sandeep Dutta

Please mark the answer correct & Helpful, if i could help you.

View solution in original post

11 REPLIES 11

SANDEEP DUTTA
Tera Patron
Tera Patron

Hi @Nisar3 ,

When you create a new sys_dictionary record to define a new string field, the max_length is mandatory. Despite the similarity of the name to HTML's maxlength attributes for input or textarea tags, this is not enforced as a limit in the client or server.

Max length is not enforced on the Now Platform

Fields in ServiceNow accept string inputs greater than the sys_dictionary max_length value. This is the expected behavior of the product.

When you create a string field in ServiceNow, the underlying column in the database is created with a default data type based in part on the specified max_length value:

  • Small (40) = varchar(40)
  • Medium (100) = varchar(100)
  • Large (1000) = mediumtext
  • Extra Large (4000) = mediumtext

Refer to below article for more details:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0685779

 

Thanks,
Sandeep Dutta

Please mark the answer correct & Helpful, if i could help you.

So what would be the size in database if max length is set to 30 in sys_dictionary? i.e after how many characters will it start truncating data?

It would be depending on how the database would create the varchar. For 30 it could be medium which is upto 100.

 

 

Thanks,
Sandeep Dutta

Please mark the answer correct & Helpful, if i could help you.

So there's no guide to know what value of max length corresponds to what size in database? What if I want to know the size in database if I set max length to 20 in sys_dictionary? How would I know that?