Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 03:19 AM
Can we call BUSINESS RULE in client script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 08:24 AM
You cannot.
But, you can create a client callable script include with the function contained in you business rule.
Then you modify the business rule to call the script include function and then you create a client script that will also call the same script include function.
Script Include
var CustomScriptInclude = Class.create();
CustomScriptInclude.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
myFunction: function () {
var recordSysID = this.getParameter('sysparm_record_sys_id');
return new global.JSON().encode(this.myFunctionServer(recordSysID));
},
myFunctionServer: function (recordSysID) {
return {
sys_id: '' + recordSysID,
result: 'Here is the result'
}
},
type: "CustomScriptInclude"
};
Business Rule
(function executeRule(current, previous /*null when async*/ ) {
var customScriptInclude = new CustomScriptInclude();
customScriptInclude.myFunctionServer('' + current.sys_id)
});
On change client script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ajax = new GlideAjax('CustomScriptInclude');
ajax.addParam('sysparm_record_sys_id', g_form.getUniqueValue());
ajax.addParam('sysparm_name', 'myFunction');
ajax.getXMLAnswer(getAnswer);
function getAnswer(result) {
var resultObj = JSON.parse(result);
gs.addInfoMessage(resultObj.result)
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 08:26 AM - edited 07-30-2025 08:31 AM
Hi @pansarepooj ,
Nope. That is the reason we have Glideajax and g_scratchpad to get server side data/code on client side.
If my answer helped you in anyways, please mark it- Solution Accepted.
Regards,
Nikhil Bajaj
Regards,
Nikhil Bajaj

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 08:29 AM
Hi @pansarepooj
No you cannot directly call BR from client script. Can you explain what are you trying to acheive?
you can use what Jean said by using script include and client script
or you can send data to client side by using display business rule with g_scratchpad
***Mark Correct or Helpful if it helps.***