Running client-side scripts
It would be inappropriate to have any chapter on client-side JavaScript without having a Hello, world!
example at some point.
ServiceNow has a very simple JavaScript executor that is the equivalent of Background Scripts, but for the browser. On almost any page, pressing Ctrl + Shift + J will launch the JavaScript execution window:
Let's run some code:
alert('Hello, world!');
Once you press the Run my code button, you should see the little pop-up alert box, as you may expect.
Your web browser executes the very simple JavaScript that you put in the window. Virtually every browser has a JavaScript console that provides the same functionality, which you will probably prefer, but it is helpful that ServiceNow gives you a simple alternative for every browser.
Scope on the client
The JavaScript executor will always run code outside of any scope. But as we journey through the platform, we'll find several places where only certain functionality is allowed, just like the...