Is having a client-callable Script Include mean that it cannot be called by server-side scripts?

Lhora Alvarez
Tera Sage

Hi all!

I have this question that keeps going around my head. I've been looking around the official docs and community, but I'm still not sure what's the right approach when it comes to calling your Script Include from both client-side and server-side.

 

I know that Script Include serves as your custom class. You use it to store and call all the reusable methods that your implementations (e.g. BR, Client Scripts) need to function.

 

So let's say that you have created a script include. This script include contains the same functions needed for both Server-side (e.g., BR) and Client-side (e.g., Catalog Client Script). It just needs to be called by the record itself.

 

Do you create 2 separate script includes (1 client-callable, the other is not), OR you create 1 client-callable script include that contains separate methods for client scripts (for GlideAjax to use) and server scripts?

 

Disclaimer: For the 1 client-callable script include, I've found community posts stating that your methods can be both server and client side. It's just a matter of checking where the parameter comes from.

 

I'm conflicted on what's considered best practice. If you can share your thoughts, that would be great.

1 ACCEPTED SOLUTION

Amit Gujarathi
Giga Sage
Giga Sage

HI @Lhora Alvarez ,
I trust you are doing great.
When you mark a Script Include as client-callable, it means that it can be accessed from the client-side scripts, like Catalog Client Scripts, using GlideAjax. This does not restrict it from being called on the server side. In fact, a client-callable Script Include can be used by both client-side and server-side scripts.


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



View solution in original post

5 REPLIES 5

I see.

A follow-up question, what about the methods inside the client-callable script include?

Do you have separate methods (that do the same thing) for server-side and client-side? OR is it better, performance-wise, to have a single method be called by both server-side and client side?

 

...or does it depend on the developer?