Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How can we use objects with get() ?

Oya Orhan
Giga Guru

Hi All,

I know the general usage of get().

  var returnValue = grIncident.get('caller_id.name’,’Jane Doe’);

or 

 var returnValue = grIncident.get('57af7aec73d423002728660c4cf6a71c’);

But in the ServiceNow documentation it is defined as:

GlideRecord - get(Object name, Object value)

Product Documentation-GlideRecord - Global

and I never used get() with objects. Have you ever used it? Could you please give me an example?

Thanks

Oya

5 REPLIES 5

Hi Hitoshi,

Thanks for your response.

I have tested the code below:

var grUser = new GlideRecord('sys_user');
if (grUser.get('62826bf03710200044e0bfc8bcbe5df1')) {
  var grCompany = new GlideRecord('core_company');
 
  grCompany.query("sys_id", grUser.company);
  while (grCompany.next()) {
     gs.info(grCompany.name);
  }
}
 
query() also accepts grUser.company. But in Help document it says query() accepts string. That's why I think whether object is something different here. Please have a look to my response to Joni.