
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 10:13 AM
I have a scoped script include that is client callable; it extends global.AbstractAjaxProcessor. I also need the same functionality conditionally called elsewhere from within the application, where the source is server side. Are there any performance implications to calling this script include from the server side, not using Glide Ajax? In the instance of the script include below, the function 'one' would be a client callable intended for passing a sysparam, while the function 'two' would take an argument meant to be called server side.
In a flow action / business rule, does calling function 'two' have any performance implications, since the script include extends global.AbstractAjaxProcessor? Calling the script include this way from server side, is it synchronous or asynchronous?
example BR/Flow Action Script:
var si = new ClientCallableSI();
var returnedValue = si.two('imaginarySysID');
// is this synchronous or asynchronous?
script include example:
(note: this is just a mock up example, i realize gs.getUser() is probably the better way to access a user object).
x_comp_app.ClientCallableSI:
var ClientCallableSI = Class.create();
ClientCallableSI.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
one: function(){
var user = this.getParameter('sysparm_user');
return this.two(user);
},
two: function(abc){
var gr = new GlideRecord('sys_user')
gr.get(abc);
return gr.department.name;
},
});
for posterity, how it would be used in a client script as Async.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('ClientCallableSI');
ga.addParam('sysparm_name','one');
ga.addParam('sysparm_user','imaginarySysID');
ga.getXML(Callback);
function Callback(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
//do whatever is needed next
}
}
Thanks in advance!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 10:28 AM
@Colin Wilson I have frequently used a client callable script include in both client and server side scripts and never faced any performance related issues. A client callable script includes allows you to call a method asynchronously, whereas if the same method called from a server side script, the method call becomes synchronous.
Generally, it is a best practice to keep the server side and client callable server side code separate if the same logic is not shared across client and server side.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 10:28 AM
@Colin Wilson I have frequently used a client callable script include in both client and server side scripts and never faced any performance related issues. A client callable script includes allows you to call a method asynchronously, whereas if the same method called from a server side script, the method call becomes synchronous.
Generally, it is a best practice to keep the server side and client callable server side code separate if the same logic is not shared across client and server side.