Client Callable Business Rules

Mark Wood
Tera Contributor

Hello Experts,

can anyone pleas guide me on what is use of client callable field on business rules can we call the business client side if yes then how? please guide me thank you.

1 ACCEPTED SOLUTION

sourav1999
Mega Guru

Yes, the 'Client Callable' field on a business rule in ServiceNow allows the business rule to be called from client-side scripts. Here's how you can use it:

 

1. Create a Business Rule: Navigate to System Definition > Business Rules and create a new business rule.

2. Set 'Client Callable' to true: In the business rule form, set the 'Client Callable' field to true. This makes the business rule accessible from client-side scripts.

3. Write your script: In the 'Script' field, write the script that you want to execute when the business rule is called.

4. Call the Business Rule from Client-Side: You can call the business rule from a client-side script using the GlideAjax object. Here's a sample code:

javascript
var ga = new GlideAjax('BusinessRuleName');
ga.addParam('sysparm_name', 'FunctionName');
ga.addParam('sysparm_parameter', 'ParameterValue');
ga.getXML(CallBackFunction);


In the above code:

- 'BusinessRuleName' is the name of your business rule.
- 'FunctionName' is the name of the function in your business rule that you want to call.
- 'ParameterValue' is the value of any parameters that your function needs.
- 'CallBackFunction' is the name of the function that will be called when the server-side function finishes executing.

5. Handle the Response: In your callback function, you can handle the response from the server-side function. Here's a sample code:

javascript
function CallBackFunction(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}


In the above code, 'answer' is the value returned by the server-side function.

 

For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - nowgpt.ai

View solution in original post

2 REPLIES 2

Bert_c1
Kilo Patron

sourav1999
Mega Guru

Yes, the 'Client Callable' field on a business rule in ServiceNow allows the business rule to be called from client-side scripts. Here's how you can use it:

 

1. Create a Business Rule: Navigate to System Definition > Business Rules and create a new business rule.

2. Set 'Client Callable' to true: In the business rule form, set the 'Client Callable' field to true. This makes the business rule accessible from client-side scripts.

3. Write your script: In the 'Script' field, write the script that you want to execute when the business rule is called.

4. Call the Business Rule from Client-Side: You can call the business rule from a client-side script using the GlideAjax object. Here's a sample code:

javascript
var ga = new GlideAjax('BusinessRuleName');
ga.addParam('sysparm_name', 'FunctionName');
ga.addParam('sysparm_parameter', 'ParameterValue');
ga.getXML(CallBackFunction);


In the above code:

- 'BusinessRuleName' is the name of your business rule.
- 'FunctionName' is the name of the function in your business rule that you want to call.
- 'ParameterValue' is the value of any parameters that your function needs.
- 'CallBackFunction' is the name of the function that will be called when the server-side function finishes executing.

5. Handle the Response: In your callback function, you can handle the response from the server-side function. Here's a sample code:

javascript
function CallBackFunction(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}


In the above code, 'answer' is the value returned by the server-side function.

 

For asking ServiceNow-related questions try this :
For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.
Link - nowgpt.ai