When creating custom solution in ServiceNow it is important to clarify the technical requirements of its functionality. After clarification it is good practice to check if the required functionality already exists in ServiceNow, either an out of the box or a custom created solution.
The needed functionality can reside in script includes or UI scripts.
It is easy to make use of these functions when you create server side script like business rules and access controls. This can be done using js.include(‘My Script.js’); in the beginning of the script, replacing My Script with your own script name.
There is no standard way of loading a server side function from a client side script like UI Actions, UI Policies or Client Scripts.
The following can be done to make this possible:
First create your server side function if it doesn’t already exist. See example in the next screenshot.

The example function “MyFunction” will pop-up a confirmation box with the option to select Ok or Cancel button. Feel free to select or create the function that you need instead of this one. Initialize is a mandatory function and make sure that the name of your UI Script or Script Include is the same name as the variable on the first line. If you are testing in Firebug, then make sure that you refresh the page after you have edited your script otherwise it might not find your function.

More info on this:
http://wiki.servicenow.com/index.php?title=Script_Includes
http://wiki.servicenow.com/index.php?title=UI_Scripts

To call this function you can use the following code:
Continue reading…»