how do I include my own javascript library on client-side

gmoore1
Tera Expert

How do I do a script include for the client-side. I would like to reuse utility functions that I have written in my client scripts. I don't want to create an onLoad function for the form that writes a script tag to the page, if Service-Now provide a method to do it.

3 REPLIES 3

Jared_Laethem
ServiceNow Employee
ServiceNow Employee

You could do a global client script(table = global). You could also put this into a script include but I am not sure where all you will have access if you put it there. You would have to do some testing. You will definitely want to be careful though what you try to include as it is easy to cause namespace collisions that will break your instance. Service-now already includes (in a script include) the prototype.js library version 1.50 although it is only a sub-set of the full library. I'm attaching the documentation for prototype 1.50 for anyone that is interested.

Anyways getting back to the idea of includingyour favorite JS library to your service-now instance; lets say that favorite library is mootools. If you include mootools you will find out that even though it has many of the same functions as prototype. Furthermore you will find that it extends many of the same built in JS objects like string, element etc. that prototype does. All I can say is that this is all bad.

If your JS library is some homebrew collection of useful functions you might not have the same issues but should probably still proceed with caution. Good luck.

ps. no luck on that attachment. I'll try and get it up as soon as possible.


also of note regarding the prototype library see Pat's post on this related thread
http://forum.service-now.com/showthread.php?t=645


Here are the docs that I promised. Have fun everyone!