- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2025 10:57 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2025 11:00 PM
Hello @redijanirud ,
This is the official documentation which you can refer to
https://developer.servicenow.com/dev.do#!/learn/learning-plans/xanadu/new_to_servicenow/app_store_le...
https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_referenc...
Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.
Thanks and Regards,
Ved
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2025 11:02 PM
Hi @redijanirud
Check the ServiceNow article below, which provides an explanation..
GlideRecord
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2025 11:04 PM
Hi @redijanirud
Please refer :
In ServiceNow, a GlideRecord is a special JavaScript class used to interact with the database. It allows you to query, update, insert, or delete records in any table in ServiceNow, similar to how you would use SQL in traditional databases.
Simple Real-Time Example :
Let’s say you work in IT support and want to find all open incidents assigned to you.
You want to get all incidents where:
- The state is not "Closed"
- Assigned to your user ID
GlideRecord Script:
var gr = new GlideRecord('incident'); // Targeting the 'incident' table
gr.addQuery('state', '!=', '7'); // State not equal to 'Closed' (state 7 = Closed)
gr.addQuery('assigned_to', gs.getUserID()); // Assigned to current user
gr.query(); // Run the query
while (gr.next()) {
gs.info('Incident Number: ' + gr.number); // Print incident number
}
Imagine you're an Infra Dev Specialist and want to automate a script that checks for stale incidents (e.g., not updated in 7 days). GlideRecord helps you fetch those records and take action—like sending reminders or escalating.
Help future readers out—mark the answer and close the thread if it helped you! 😊
If this response resolved your issue, kindly mark it as Helpful or Accept Solution—it helps others find the answer faster.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2025 11:00 PM
Hello @redijanirud ,
This is the official documentation which you can refer to
https://developer.servicenow.com/dev.do#!/learn/learning-plans/xanadu/new_to_servicenow/app_store_le...
https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/app-store/dev_portal/API_referenc...
Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.
Thanks and Regards,
Ved
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2025 11:02 PM
Hi @redijanirud
Check the ServiceNow article below, which provides an explanation..
GlideRecord
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2025 11:04 PM
Hi @redijanirud
Please refer :
In ServiceNow, a GlideRecord is a special JavaScript class used to interact with the database. It allows you to query, update, insert, or delete records in any table in ServiceNow, similar to how you would use SQL in traditional databases.
Simple Real-Time Example :
Let’s say you work in IT support and want to find all open incidents assigned to you.
You want to get all incidents where:
- The state is not "Closed"
- Assigned to your user ID
GlideRecord Script:
var gr = new GlideRecord('incident'); // Targeting the 'incident' table
gr.addQuery('state', '!=', '7'); // State not equal to 'Closed' (state 7 = Closed)
gr.addQuery('assigned_to', gs.getUserID()); // Assigned to current user
gr.query(); // Run the query
while (gr.next()) {
gs.info('Incident Number: ' + gr.number); // Print incident number
}
Imagine you're an Infra Dev Specialist and want to automate a script that checks for stale incidents (e.g., not updated in 7 days). GlideRecord helps you fetch those records and take action—like sending reminders or escalating.
Help future readers out—mark the answer and close the thread if it helped you! 😊
If this response resolved your issue, kindly mark it as Helpful or Accept Solution—it helps others find the answer faster.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2025 11:07 PM
Hello @redijanirud ,
In ServiceNow, GlideRecord is a fundamental and incredibly powerful JavaScript class that provides the primary way to interact with the ServiceNow database from server-side scripts.
GlideRecord is a built-in class in ServiceNow's server-side scripting environment.
Why we used -
In ServiceNow, GlideRecord is a fundamental and incredibly powerful JavaScript class that provides the primary way to interact with the ServiceNow database from server-side scripts. Think of it as ServiceNow's equivalent to SQL queries, but within a JavaScript context.
What it is:
A JavaScript Class: GlideRecord is a built-in class in ServiceNow's server-side scripting environment.
Database Interaction: Its core purpose is to enable scripts to perform CRUD (Create, Read, Update, Delete) operations on records stored in any table within the ServiceNow database.
Why it's used:
Querying Data (Read): This is perhaps its most common use. You can define conditions (like addQuery(), addEncodedQuery()) to filter records and then iterate through the results using query() and next().
Inserting New Records (Create): You can create a new GlideRecord object, set its field values, and then use insert() to add a new record to the table.
Updating Existing Records (Update): You can query for existing records, modify their field values, and then use update() to save the changes to the database. You can update single records or multiple records with updateMultiple().
Deleting Records (Delete): You can query for records and then use delete() or deleteMultiple() to remove them from the table.
Server-Side Scripting: GlideRecord is predominantly used in server-side scripts such as:
- Business Rules: To automate actions based on record events (e.g., when an incident is created, update a related record).
- Script Includes: To create reusable server-side functions that can be called from various scripts.
- UI Actions (Server-side): To perform database operations when a user clicks a button.
- Scheduled Jobs: For batch processing and data manipulation at specific times.
- Workflows and Flow Designer: To interact with records within automated processes.
You can refer the below links -
Thank you.