String field 4000 character limit curiosity (is it actually 16,777,215 characters?)

AaronO
Tera Contributor

Hello,

With reference to 

https://www.servicenow.com/community/developer-forum/string-field-with-max-limit-4000-accepts-more-t...

 

Unfortunately, it contains some dead links to the old ServiceNow Wiki.  So I feel justified making this a new post.

 

Reading the comment by dantenow (ServiceNow Employee) it said that a string field set to max length of 4000 is in fact 16,777,215 characters.

 

Interestingly, reading other articles on the web, I hear that the limit is 4,000.

 

I tested this myself (with max length being 4,000) and confirmed I was able to go over 5,000 characters.

 

I increased the max length of the dictonary entry to 10,000 saved it, then back to 4,000 and I got this error (not allowed to save):

 

Length change not allowed. The field 'Recipients People' on table 'Outage Email Event' contains existing data records (1) that exceed the new length of 4000.

 

I changed dictionary entry back to 10,000 and this was ok.

 

So my question is, is the string field maximum really 16,777,215 characters?

1 ACCEPTED SOLUTION

Hayo Lubbers
Kilo Sage

Hi @AaronO ,

 

Have a look at : https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0685779

 

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

Any string field that is larger than varchar(255) is given the mediumtext data type. In the client, it will be represented as an HTML textarea, instead of an HTML input. The maximum length of mediumtext is 16,777,215 bytes.

 

Hope this helps,

Hayo

View solution in original post

1 REPLY 1

Hayo Lubbers
Kilo Sage

Hi @AaronO ,

 

Have a look at : https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0685779

 

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

Any string field that is larger than varchar(255) is given the mediumtext data type. In the client, it will be represented as an HTML textarea, instead of an HTML input. The maximum length of mediumtext is 16,777,215 bytes.

 

Hope this helps,

Hayo