Building Script Libraries

In the time I’ve been working with ServiceNow, I’ve seen a lot of people using Script Includes to develop code that, in theory, will be reusable.  This is a great thing.  However, if you don’t pay attention, the number of script includes quickly becomes overwhelming and you loose track of what you (or someone else) has developed.  As a result, its not uncommon to have numerous routines that essentially perform the same set of functionality, but because they were unknown by another developer in the system, it went un-reused.

What I’ve found very useful is to put some structure around the creation of your Script Includes to encourage reuse and make it much easier for other developers to find routines that could help them.  First, I’ll highlight what a typical Script Include looks like and then transform that into a structure that allows for both server-side and client-side calls to be made to a common library of functions.

Continue reading