Business Rule access to current


The Business Rule page (http://wiki.servicenow.com/index.php?title=Business_Rules#Global_Busines...) documents the predefined variables current, previous, g_scratchpad and gs.

After some testing of a global Business Rule which includes code outside of a function, it appears that while the gs variable is defined and use-able, the current variable is undefined.

Is this a bug in the system implementation or the documentation?


If the doc says or implies

If the doc says or implies that "current" exists for such a Business Rule, it is wrong. It isn't, nor is it intended to be.

Such a rule (global, with script outside of a function) will end up running far more than many people realize. Create one with a gs.log() statement, wait a bit, and look in the log at how many times it's run - even without any user transactions.

Global Business Rules should be avoided in favor of Script Includes that can also defined global functions. The difference being that the function in the Script Include is only loaded/parsed on demand, whereas the all functions in all global Business Rules are loaded/parsed for every transaction. Gets expensive if their number grows significantly.

ServiceNow EmployeeServiceNow Moderator

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.