Prasanna
Prasanna

Reputation: 440

how to call a business rule from client script

I understand that glideAjax can be used to call a business rule from client script. But wiki says below

Do not create a business rule, but instead navigate to System Definition > Script Include and create a new script

Can some one help me understand how does one call a business rule which is 'client callable' from a client script using glide ajax

Upvotes: 2

Views: 6390

Answers (1)

Joey
Joey

Reputation: 2951

I don't think you want a business rule. A business rule is something that is intended to run an arbitrary server-side script any time a record in a particular table is updated which meets a particular condition.

There exists the concept of a global business rule which allows you to basically define a function that will exist in the global scope, making it callable most anywhere server-side, but you should avoid global business rules. Just like in general programming best practices, you don't want to be defining things in the global scope/context. This is especially problematic with javascript in ServiceNow. Just avoid bleeding into the global scope and save yourself a world of hurt.

What you actually want is a client-callable Script Include, which is just a place for you to define a script-defined object, which you can call using GlideAjax.

The wiki on GlideAjax includes a pretty straightforward example on how to define a client-callable Script Include (which is server-side) that you can invoke from a client script (which is client-side).

Upvotes: 2

Related Questions