GlideRecord - get(Object name, Object value)

Creates a GlideRecord based on a specified 'name = value' pair.

If the value parameter is not specified, then the method assumes the name parameter contains the sys_id.

Note: If you only pass a single parameter into this method, and that parameter is not the sys_id, the system performs a search across multiple fields (sys_id, name, number, so on). This action causes the system to try to create multiple records, which fails, and generates "duplicate record" error messages. To fix this problem, modify your method call to either contain both parameters or ensure that the passed-in parameter is the sys_id.

This method is meant for the query of single records. Therefore, the system performs a 'next' operation on the record before returning.

Table 1. Parameters
Name Type Description
name Object Field name
value Object Optional. Value to match
Table 2. Returns
Type Description

True = GlideRecord was created

False = GlideRecord was not created

Scoped equivalent

To use the get() method in a scoped application, use the corresponding scoped method: Scoped GlideRecord - get(Object name, Object value).

function kbWriteComment(id, comments) {
 var fb = new GlideRecord('kb_feedback');
 fb.article = id;
 fb.comments = comments;
function kbGetText(id) {
 var gr = new GlideRecord('kb_knowledge');
 if (gr.get(id)) {
 gr.u_times_used = gr.u_times_used + 1;
 gr.u_last_used = gs.nowDateTime();
 // return "Knowledge article " + gr.number + ":\n" +
 // "[code]" + gr.text + "[/code]";
 return gr.number;