The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Can Script Include have code exceeding 500 lines ?

sakshi garg
Giga Contributor

We are trying to publish our app in Servicenow appstore . As per the certification policy it is mentioned "Large scripts (larger than 500 lines) should be converted into script includes wherever possible."

Does this apply to Script Includes also? Can script include exceed 500 lines of code or does it need to be broken down into further script includes?

 

Thanks,

Sakshi Garg

"

1 ACCEPTED SOLUTION

Kartik Sethi
Tera Guru
Tera Guru

Hi @sakshi garg 

As per the best practices Business Rule (and other Server Side scripting components except Script Include) should be concise and should call Script Include if there are complex logic involved.

Script Include's script field has length = 4000 which does not mean that it will have 4000 characters. Refer the detail from ServiceNow KB article "Fields in ServiceNow accept string inputs greater than the sys_dictionary max_length value [KB068577..."

  • 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.

So any code which is under 16MB can be accepted by ServiceNow which is a very big size for code. Considering performance, Script Include is called on demand and it will not put much load on the database unless you have exhausted the 16MB size.


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik

View solution in original post

4 REPLIES 4

Musab Rasheed
Tera Sage
Tera Sage

Hello,

No problem in keep more than 500 hundred lines in Script include, I see in my instance there are OOB code which have more than 500 lines

Please hit like and mark my response as correct if that helps

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

why not?

Even OOB script includes have more lines than 500.

You can always break it down but it causes more scripts to be maintained.

regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Kartik Sethi
Tera Guru
Tera Guru

Hi @sakshi garg 

As per the best practices Business Rule (and other Server Side scripting components except Script Include) should be concise and should call Script Include if there are complex logic involved.

Script Include's script field has length = 4000 which does not mean that it will have 4000 characters. Refer the detail from ServiceNow KB article "Fields in ServiceNow accept string inputs greater than the sys_dictionary max_length value [KB068577..."

  • 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.

So any code which is under 16MB can be accepted by ServiceNow which is a very big size for code. Considering performance, Script Include is called on demand and it will not put much load on the database unless you have exhausted the 16MB size.


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik

Hi @Kartik Sethi -- Is max. size for a script string not 32MB? See the dictionary below and also here. What do you think?

 

JacquesClement_0-1695119623581.png