Any developer knows the feeling “I think I have done this before, but where is this code?”
In this short article I would like to show some (obvious) advantages of using Script Includes to their fullest.
There are several reasons to move as much server side code as possible to Script Includes.
First of all Script Includes are accessible from any other server side code, and secondly they will only be accessed whenever they are actually needed (which prevents unnecessary checks in Business Rules that will not run anyway).
Recommendation is to set up a script include for every table that has any custom methods.
Depending on the exact setup, you can decide what your initialization should look like:

Name: CustomTableUtilsClass
Description: Class that contains methods that may be used on several occasions
[cc lang=”javascript”]
var CustomTableUtilsClass=Class.create();

// initialize your class.
initialize: function(gr){
// the parameters that you define here, depend on requirement.
// you can pass the GlideRecord,
// or just the sys_id of the current record.
// if the methods have nothing to do with “CustomTable”,
// then it may be wise(r) to define the functions
// in a separate Script Include

// declare the functions that are available for the developer
Functionality1: function(){
var sResult=this._doStuffWith(this.curRecord);
return sResult;

// set up some assisting functions
var sClass=gRecord.getClassDisplayValue();
return sClass;

type: CustomTableUtilsClass

So far pretty straight forward, right?
Continue reading…»