Client Script that runs on every page

gaz624
Mega Contributor

Hi,

Is is possible to run a client script on every page? A global client script that could be run. Is it also possible to also have a global business rule ..one that does't require you to set a table?

Thanks

10 REPLIES 10

I have to argue this, a global business rule is NOT like a script include. A script include is specifically called to run, a global business rule will load on EVERY transaction. You absolutely want to do do a script over a global business rule whenever possible.


A Global Business Rule gets loaded all the time, but the code inside it is always wrapped in a function that must be called.   Global Business rules are often utilized as a place for referenceQualifier functions (like getMyGroups).



I would always encourage ScriptIncludes as a better place to put these, but a Global Business Rule is not running on an insert/update to a specific table


I hear what you are saying, but why would you do this and incur the extra overhead, slight though it may be per transaction. It would have to be a very rare situation where the same thing could not be accomplished with a script include and incur no unnecessary overhead.



Per the ServiceNow Business Rule best practices: Global business rules have no condition or table restrictions and load on every page in the system. Most functions defined in global business rules are fairly specific, such as an advanced reference qualifier on one field of one form. There is no benefit to loading this kind of script on every page.


I completely agree, I have never created a Global Business Rule myself, but there is nearly 100 OOB ones.   Either way, I was answering the OP about whether it was possible.


Just to jump in sideways 😃



I heard that Global BRs is what was used before Script Include existed... And it hard to make those who started at that time to perhaps configure away from all those OOB global BRs and that the reason they still around.



//Göran