The Now Platform® Washington DC release is live. Watch now!
In a conversation I had with a customer the other day, she asked me why she saw so many examples of business rules written in functions, like this:
doImportantStuff();
function doImportantStuff() {
var x = 15;
var y = 22.3;
var z = Math.pow(15, 22.3);
current.answer = z;
}
var x = 15;
var y = 22.3;
var z = Math.pow(15, 22.3);
current.answer = z;
object is the global object; in server-side JavaScript on the Service-now.com platform, the global object is just an ordinary JavaScript object, with no special features or properties. So that simpler-looking version of the business rule defines three new (maybe) properties on the global object:
window
,
x
, and
y
.
z
// business rule 1...
var x = 15;
// business rule 2...
if (current.name == 'magic value')
x = true;
current.description = '';
if (x)
current.magic = true;
. In the second business rule,
x
will always evauate to true, no matter what is in
x
— because
current.name
is a global property common to both business rules.
x
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.