Querying multiple records from a table and processing

venkatraman2
Tera Contributor

Hi,

I need to retrieve records from a custom table. It may be single record or multiple records. Can i retrieve it using gliderecord? And I need to retrieve some of the column value of each record. How can we achieve this? 

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello @venkatraman ,

yes if you want to get any record from any OOB or custom table you need to use glide record .

Here is one example which glides incident table and gets a field or column value called "priority"

var gr= new GlideRecord('incident');    // glide your table
gr.addQuery('category','hardware');  // add your query and pick up records 
gr.setLimit(1); // limit your records "Note:" remove this if multiple records
gr.query(); // process the query 
if(gr.next()) / check if record exists with the above query "Note": give while if multiple records 
{
var pt = gr.priority; // get the column name
}

Please refer to this below link of service now docs which gives you an idea about glide record and its syntax

https://developer.servicenow.com/dev.do#!/learn/learning-plans/quebec/new_to_servicenow/app_store_le...

Please mark my answer correct if it helps you

View solution in original post

1 REPLY 1

Mohith Devatte
Tera Sage
Tera Sage

Hello @venkatraman ,

yes if you want to get any record from any OOB or custom table you need to use glide record .

Here is one example which glides incident table and gets a field or column value called "priority"

var gr= new GlideRecord('incident');    // glide your table
gr.addQuery('category','hardware');  // add your query and pick up records 
gr.setLimit(1); // limit your records "Note:" remove this if multiple records
gr.query(); // process the query 
if(gr.next()) / check if record exists with the above query "Note": give while if multiple records 
{
var pt = gr.priority; // get the column name
}

Please refer to this below link of service now docs which gives you an idea about glide record and its syntax

https://developer.servicenow.com/dev.do#!/learn/learning-plans/quebec/new_to_servicenow/app_store_le...

Please mark my answer correct if it helps you