What is the Maximum Lines of Code allowed for a single Script Include

Chris L5
Tera Contributor

What is the Maximum Lines of Code allowed for a single Script Include ?

I am not have much luck finding any article that provides a hard and fast maximum limit to the number of lines of JavaScript that a Script Include can have.

I have about 3 thousand lines of Javascript spread across three subflows (Script Activities) and a few Server Side Script Includes.

I would like to move all of my JavaScript from the Script Activities and move them to Script Includes.  There are details as to why I am doing this..  but it beyond the context of the question.   For the moment, I have to put all of the code into one Script Include (if possible). 

Is there a limit to how much code Service Now will allow per Script Include ?

Personally and Professionally, I would prefer things broken down into many smaller Script Includes.. but for the moment,, I have been out-voted. Will keep fighting the good fight.

In the mean time.. I would like to know what the Best Practice / Hard limit (if any) is on the number of lines of code per Script Include.

 

 

 

 

1 ACCEPTED SOLUTION

Good call and I stand humbly corrected. I didn't realize that anything over 255 characters is basically unlimited. 

Seems like it's related to the way the field is converted to a data type in the database when it is created. 

https://hi.service-now.com/kb_view.do?sysparm_article=KB0685779

Looks like there IS a limit, but it is such that you would find it difficult reach!

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

Thats about, oh, 250 books worth of storage in a single field!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

6 REPLIES 6

Dhananjay Pawar
Kilo Sage

Hi,

Line size is not fixed, You can write lines as much you want.

Thanks,

Dhananjay

Michael Jones -
Giga Sage

There is not a maximum number of lines per se, but there is a maximum character limit to the script field. 

Out of the box it is 8000 characters and anything more would be truncated. You can increase that if needed however. 

 

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

This is incorrect.  Any dictionary field with a 'Max Length' of 4000 or greater is really unlimited.  You can prove this by printing the length of just about any OOB Script Include.  ApplicationDependencyMapping is over 61k characters as an example.

 

Good call and I stand humbly corrected. I didn't realize that anything over 255 characters is basically unlimited. 

Seems like it's related to the way the field is converted to a data type in the database when it is created. 

https://hi.service-now.com/kb_view.do?sysparm_article=KB0685779

Looks like there IS a limit, but it is such that you would find it difficult reach!

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

Thats about, oh, 250 books worth of storage in a single field!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!