- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2015 04:51 PM
How do I call my library from a Client Script?
---
gives me an undefined error message.
*The syntax is a little off and I dare not use x as a variable. I am just trying to figure out how to call the SI from the CS.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2015 08:19 PM
Hi Jeremy,
I am not sure how complex your script include is, but remember that you can use a slimmed down GlideRecord object from client scripts.
If you do end up going with GlideAjax, here are some pointers to begin with:
1. Delete the empty initialize function in your script include, as it will break the Abstract Ajax Processor
2. Make sure you include the Object.extendsObject(AbstractAjaxProcessor part of the Script Include, this is what provides the wiring for GlideAjax to work
3. Don't forget to mark the Script Include as Client Callable
4. Use the <GlideAjaxObject>.addParam function in the client script and this.getParameter in the Script Include to pass a variable from client to server.
5. Remember you can only send string parameters from client to server. If you need to send Arrays, Objects or other complex data then you can use JSON.stringify on the client script and new JSON().decode to pass JSON data to the server
6. Likewise, you can use new JSON().encode on the server and JSON.parse on the client to pass JSON data from the server back to the client
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2015 07:40 PM
Hi Jeremy,
It looks like your library is a Script Include. If this is the case, Script Includes are server side while UI Scripts are client side, so you need to use GlideAjax to bridge the gap. If your library is built into a UI Script, then you will need to make sure it is accessible from the form on which your Client Script is used by most likely using a UI Macro and a Formatter to add the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2015 07:49 PM
This is what I was afraid of. Time to learn GlideAjax !
Thank you Travis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2015 08:19 PM
Hi Jeremy,
I am not sure how complex your script include is, but remember that you can use a slimmed down GlideRecord object from client scripts.
If you do end up going with GlideAjax, here are some pointers to begin with:
1. Delete the empty initialize function in your script include, as it will break the Abstract Ajax Processor
2. Make sure you include the Object.extendsObject(AbstractAjaxProcessor part of the Script Include, this is what provides the wiring for GlideAjax to work
3. Don't forget to mark the Script Include as Client Callable
4. Use the <GlideAjaxObject>.addParam function in the client script and this.getParameter in the Script Include to pass a variable from client to server.
5. Remember you can only send string parameters from client to server. If you need to send Arrays, Objects or other complex data then you can use JSON.stringify on the client script and new JSON().decode to pass JSON data to the server
6. Likewise, you can use new JSON().encode on the server and JSON.parse on the client to pass JSON data from the server back to the client
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2016 03:34 PM
Hey Jeremy -- I think I can help you out with picking up the whole GlideAjax and asynchronous/client-server-scripts thing. At least, I hope I can! I wrote a rather detailed article on the topic here: http://snprotips.com/blog/2016/2/6/gliderecord-client-side-vs-server-side
SN Pro Tips — GlideRecord & GlideAjax: Client-Side Vs. Server-Side
Hope this helps! 🙂