Can you call a script include from a client script - without GlideAjax?

asd13
ServiceNow Employee
ServiceNow Employee

This is more of a curiosity question rather than trying to solve a particular problem and I know best practice says always use ajax, yada yada.   I was just trying to test a simple class create SI from a client script and thought I could declare and call the SI function without the ajax gubbins but I haven't had any joy.   The SI call works as expected from server-side script so it's not syntax related - and the SI is client-callable.   There are also a bunch of standard client-callable SI's which ship as standard... so


do I need to use GlideAjax with a SI I want to access client-side?


thanks!

David

1 ACCEPTED SOLUTION

Hi David, actually in that thread I later mention i was wrong and confirmed that it's true that from the client you can only call a script include through a GlideAjax. The good news (in a way )... is that you have an alternative which is to use an asynchronous Glide Record to perform the same query you have in the script include.



Thanks,


Berny


View solution in original post

9 REPLIES 9

Hi David, actually in that thread I later mention i was wrong and confirmed that it's true that from the client you can only call a script include through a GlideAjax. The good news (in a way )... is that you have an alternative which is to use an asynchronous Glide Record to perform the same query you have in the script include.



Thanks,


Berny


Now... if you're objective is to call getTableExtensions (the out of the box function)... then that's whole different beast because it's an OOB method which does not extends from AbstractAjaxProcessor.



Perhaps the key question on this situation is "why would you need to call that method from a client script"? Isn't it something that you may be better of doing in the server side anyway?



Thanks,


Berny


Perhaps it is time to step away from the solution and ask



What is the outcome you are trying to achieve?



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

asd13
ServiceNow Employee
ServiceNow Employee

Thanks for your help guys.   I was being a bit lazy with some testing I was doing so looking for a shortcut (in the best traditions of development )       Anyway - it peaked my interest and led down that rabbit hole and I got to learn about UI Scripts and async GlideRecord from the client.



cheers!


If you would like to know a little more, GlideAjax is still considered best practice over asynchronous GlideRecord.
Async GlideRecord returns all the data associated with that record to the client, where as with GlideAjax you can return only the data you need to the client. It does come with an additional complexity over head though.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022