Can I Use GlideRecord into UI Action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 07:07 AM
Hi guys,
I have a UI Action client-server. Can I use GlideRecord object? It's a good practice or I have to use GlideAjax with Script Include?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 07:56 AM
Hi Gaetano,
The reason for using a GlideAjax call over a GlideRecord call is twofold. GlideRecord is are no longer recommended due to their performance impact. A GlideRecord call retrieves all fields in the requested GlideRecord when most cases only require one field.
A GlideAjax call is definitely the way to go.
Please mark this response as correct and helpful via your post link (Can I Use GlideRecord into UI Action? ) to help others with the same question.
Thanks,
Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 08:15 AM
I have just used GlideRecord on client UI Action and it not working!
Therefore, GlideRecord working only in server portion ...
Do you agree?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 08:38 AM
Hi Gaetano,
Unfortunately no. It is possible to call a GlideRecord within a client UI Action. (See below script - this is a test script for demonstrating this use case only), however as Chuck and I have stated, just because something is possible, it doesn't mean you should follow this practice. A GlideRecord call is synchronous, the aync GlideAjax call is definitely the way to go.
Script for client UI action using GlideRecord (NOT RECOMMENDED)
Gaetano - Please mark this response as correct and helpful via your post link (Can I Use GlideRecord into UI Action? ) to help others with the same question.
Thanks,
Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 09:20 AM
Robbie,
thank you for example, now I understand!
but...
If I use GlideAjax, it uses a Script Include function.
var ga = new GlideAjax('HelloWorld');
ga.addParam('sysparm_name','helloWorld'); // this is script include function
ga.addParam('sysparm_user_name',"Bob");
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
}
helloWorld is the function.
How it is implemented? Use GlideRecord to retrive the data?
Moreover,
If I have to wait a response from my GlideAjax to continue the workflow, I don't use an asynch function but synch function...
Do you agree?