I had question recently asked me in an interview.. and the question is Explain me about glide record script step wise?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2017 11:14 AM
Explain me about glide record script step wise..
Can anyone tell me about it what does it mean?@
- Labels:
-
Personal Developer Instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2017 11:38 AM
GlideRecord is a special Java class (GlideRecord.java) that can be used in JavaScript exactly as if it was a native JavaScript class.
GlideRecord
- is used for database operations instead of writing SQL queries.
- is an object that contains zero or more records from one table. Another way to say this is that a GlideRecord is an ordered list.
you can find more information below.
if you have any specific questions post it here someone will answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2017 12:04 PM
Hi,
srnewbie has already mentioned the basic of Glide Record,i.e. what it is, why we should use.
I'm just providing some information on how to apply, where to apply with one basic example. From coding perspective you can/able to do Glide query from both Client side (Client script, UI Script etc) and Server side (Business rules, Script include etc). But the best practice says to use it in the server side and then call it in client side. Well, sounds complex? So here I'm providing one simple example which will help you to understand step by step.
In order to query a table, first create a ServiceNow object for the table. This object is called a GlideRecord.
var gr = new GlideRecord('incident'); //So here the object is 'gr' which is the Glide Record object for Incident table.
Lets say you wanted to find all incidents where the priority field is GREATER THAN 1. In that case you have to provide us with the operator that you want to apply to priority and this is done by providing the operator in the addQuery() request as is shown below.
var gr = new GlideRecord('incident');
gr.addQuery('priority', '>', 1); //It is querying Incident table which has record with Priority greater than 1
gr.query(); // Issue the query to the database to get relevant records.
while (gr.next()) {
// add code here to process the incident record
// lets say you want to show an alert message
alert('Yepiee....I got Glide query');
}
Hope, it clears your idea a bit. Please go through this wiki article to get cleared in depth Using GlideRecord to Query Tables - ServiceNow Wiki .
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 10:17 PM
Hi nrk'skittu,
By any chance, did you able to see my last response?
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:35 AM
Hi nrk'skittu,
May I know the status of this thread? By any chance did you able to see my last response?
If I have answered your question, would you mind to mark the Answer Correct and close the thread. So that it can be tracked later by others in need.